/* middleschoolgpacalculator.org — clean, friendly education design.
   Light theme, deep blue primary, warm amber accent, system fonts only. */

:root {
  --blue: #17457e;
  --blue-dark: #0f3260;
  --blue-soft: #e8f0fa;
  --amber: #d97706;
  --amber-soft: #fdf3e3;
  --ink: #1c2733;
  --muted: #51606f;
  --line: #d7e0ea;
  --card: #ffffff;
  --bg: #f6f9fc;
  --good: #177245;
  --radius: 14px;
  --shadow: 0 2px 6px rgba(23, 69, 126, 0.08), 0 10px 28px rgba(23, 69, 126, 0.07);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
}

h1, h2, h3 { line-height: 1.25; color: var(--blue-dark); margin: 0 0 0.6em; }
h1 { font-size: clamp(1.7rem, 1.2rem + 2.4vw, 2.6rem); }
h2 { font-size: clamp(1.35rem, 1.1rem + 1.2vw, 1.9rem); margin-top: 0; }
h3 { font-size: clamp(1.05rem, 1rem + 0.4vw, 1.25rem); }
p { margin: 0 0 1em; }
a { color: var(--blue); }
a:hover { color: var(--blue-dark); }

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap { max-width: 1020px; margin: 0 auto; padding: 0 1rem; }

/* ---------- Header / nav ---------- */
.site-header {
  background: var(--blue-dark);
  color: #fff;
}
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.5rem;
  padding-top: 0.7rem; padding-bottom: 0.7rem;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.12rem; display: inline-flex; align-items: center; gap: 0.55rem; }
.brand-logo { width: 38px; height: 38px; flex: 0 0 auto; }
.brand span { color: #fbbf24; }
.site-nav { margin-left: auto; }
.site-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem 1.1rem; margin: 0; padding: 0; }
.site-nav a { color: #dbeafe; text-decoration: none; font-size: 0.95rem; }
.site-nav a:hover { color: #fff; text-decoration: underline; }

/* ---------- Hero + calculator ---------- */
.hero { background: linear-gradient(180deg, var(--blue-soft), var(--bg)); padding: 2rem 0 1rem; }
.hero .sub { font-size: 1.08rem; color: var(--muted); max-width: 46rem; }

.calc-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin: 1.25rem 0 2rem;
}
.calc-card h2 { margin-bottom: 0.25rem; }
.calc-intro { color: var(--muted); margin-bottom: 1rem; }

fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 0.75rem 1rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 600; color: var(--blue-dark); padding: 0 0.35rem; }
.radio-row { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.radio-row label, .check-label { display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer; min-height: 48px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--blue); width: 1.15rem; height: 1.15rem; }

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.field label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.3rem; color: var(--blue-dark); }
.field select, .field input[type="text"], .field input[type="number"] {
  width: 100%;
  font-size: max(1rem, 1em);
  min-height: 48px;
  padding: 0.55rem 0.7rem;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
}
.toggle-row { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; align-items: center; }

.preset-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.5rem 0 1rem; }
.preset-row .preset-label { font-weight: 600; color: var(--blue-dark); margin-right: 0.25rem; }

.btn {
  font: inherit; font-weight: 600;
  min-height: 48px;
  padding: 0.55rem 1.1rem;
  border-radius: 9px;
  border: 1.5px solid var(--blue);
  background: var(--blue);
  color: #fff;
  cursor: pointer;
}
.btn:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-secondary { background: #fff; color: var(--blue); }
.btn-secondary:hover { background: var(--blue-soft); color: var(--blue-dark); }
.btn-amber { background: var(--amber); border-color: var(--amber); color: #fff; }
.btn-amber:hover { background: #b45309; border-color: #b45309; }
.btn-remove {
  background: #fff; color: #b3261e; border-color: #e3b6b2;
  min-height: 48px; align-self: end;
}
.btn-remove:hover { background: #fdeceb; border-color: #b3261e; color: #b3261e; }

.course-rows { display: grid; gap: 0.75rem; margin-bottom: 1rem; }
.course-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) auto;
  gap: 0.75rem;
  align-items: end;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
}
.course-row .field label { margin-bottom: 0.2rem; }
.field-honors { align-self: end; }
.field-honors .check-label { min-height: 48px; }

.calc-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }

.result-panel {
  margin-top: 1.25rem;
  background: var(--blue-dark);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 1rem;
  align-items: center;
}
.result-panel .result-label { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: #bfdbfe; margin: 0; }
.result-gpa { font-size: clamp(2.2rem, 1.6rem + 2.5vw, 3.2rem); font-weight: 800; line-height: 1.05; margin: 0; color: #fff; }
.result-stat { font-size: 1.5rem; font-weight: 700; margin: 0; color: #fff; }
.result-verdict { grid-column: 1 / -1; font-size: 1.08rem; font-weight: 600; margin: 0; color: #fde68a; }
.result-note { grid-column: 1 / -1; margin: 0; color: #dbeafe; font-size: 0.92rem; }

/* ---------- Content sections ---------- */
.content-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin: 0 0 1.5rem;
}
.content-section ul, .content-section ol { margin: 0 0 1em; padding-left: 1.4rem; }
.content-section li { margin-bottom: 0.45rem; }
.lede { font-size: 1.06rem; color: var(--muted); }
.callout {
  background: var(--amber-soft);
  border-left: 4px solid var(--amber);
  border-radius: 0 10px 10px 0;
  padding: 0.9rem 1.1rem;
  margin: 1rem 0;
}
.callout p:last-child { margin-bottom: 0; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.card-link {
  display: block; text-decoration: none;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem; background: #fbfcfe; color: var(--ink);
}
.card-link:hover { border-color: var(--blue); background: var(--blue-soft); }
.card-link h3 { margin-bottom: 0.35rem; }
.card-link p { color: var(--muted); margin: 0; font-size: 0.95rem; }

/* ---------- Tables ---------- */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 1rem 0;
}
.table-scroll:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
table { border-collapse: collapse; width: 100%; min-width: 480px; }
caption { text-align: left; font-weight: 600; color: var(--blue-dark); padding: 0.7rem 0.9rem; }
thead th {
  position: sticky; top: 0;
  background: var(--blue); color: #fff;
  text-align: left; padding: 0.6rem 0.9rem; font-size: 0.93rem;
}
tbody td { padding: 0.55rem 0.9rem; border-top: 1px solid var(--line); }
tbody tr:nth-child(even) { background: #f4f8fc; }

/* ---------- FAQ ---------- */
details {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.25rem 1rem;
  margin-bottom: 0.6rem;
  background: #fbfcfe;
}
summary { font-weight: 600; color: var(--blue-dark); cursor: pointer; padding: 0.7rem 0; min-height: 48px; }
details p { color: var(--ink); }

/* ---------- Founder ---------- */
.founder { display: flex; gap: 1.1rem; align-items: flex-start; flex-wrap: wrap; }
.avatar {
  flex: 0 0 auto;
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 700;
  object-fit: cover;
}
.founder blockquote { margin: 0.4rem 0; font-style: italic; color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer { background: var(--blue-dark); color: #dbeafe; margin-top: 2.5rem; padding: 1.75rem 0; }
.site-footer a { color: #fff; }
.site-footer ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; padding: 0; margin: 0 0 0.75rem; }
.site-footer p { margin: 0; font-size: 0.92rem; }

/* ---------- How-to steps as cards ---------- */
.steps-grid {
  list-style: none;
  margin: 1.25rem 0 0.5rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.step-card {
  background: var(--blue-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem 1.15rem;
}
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--blue); color: #fff; font-weight: 700; font-size: 1.05rem;
  margin-bottom: 0.6rem;
}
.step-title { display: block; color: var(--blue-dark); font-size: 1.05rem; margin-bottom: 0.35rem; }
.step-card p { margin: 0; }

/* ---------- Weighted vs unweighted infographic ---------- */
.compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.25rem 0 0.75rem;
}
.compare-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem 1rem;
}
.compare-unweighted { background: var(--blue-soft); }
.compare-weighted { background: var(--amber-soft); }
.compare-title { margin: 0 0 0.35rem; }
.compare-badge {
  display: inline-block;
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.02em;
  padding: 0.15rem 0.6rem; border-radius: 999px;
  background: var(--blue); color: #fff;
  margin-bottom: 0.8rem;
}
.compare-weighted .compare-badge { background: var(--amber); }
.compare-rows { list-style: none; margin: 0 0 0.9rem; padding: 0; }
.compare-rows li {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.35rem 0; border-bottom: 1px dashed var(--line);
}
.compare-rows li:last-child { border-bottom: none; }
.compare-rows strong { color: var(--blue-dark); font-size: 1.05rem; }
.compare-meter {
  position: relative; height: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  margin: 0.4rem 0 0.55rem;
}
.meter-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; }
.meter-u { width: 80%; background: var(--blue); }
.meter-w { width: 90%; background: var(--amber); }
.meter-cap {
  position: absolute; left: 80%; top: -4px; bottom: -4px;
  border-left: 2px dashed var(--ink); opacity: 0.55;
}
.compare-max { margin: 0; font-size: 0.95rem; }
.compare-note { font-size: 0.9rem; color: var(--muted); margin: 0 0 1rem; }

/* ---------- Good-GPA band cards ---------- */
.band-list { list-style: none; margin: 1.25rem 0 0.5rem; padding: 0; display: grid; gap: 0.85rem; }
.band-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--muted);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}
.band-card p { margin: 0; }
.band-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 0.9rem;
  margin-bottom: 0.4rem;
}
.band-letter { font-size: 1.3rem; font-weight: 800; color: var(--blue-dark); }
.band-range { font-weight: 700; color: var(--ink); }
.band-badge {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em;
  padding: 0.14rem 0.6rem; border-radius: 999px; color: #fff; background: var(--muted);
}
.band-excellent { background: #e7f6ee; border-left-color: var(--good); }
.band-excellent .band-letter { color: var(--good); }
.band-excellent .band-badge { background: var(--good); }
.band-strong { background: var(--blue-soft); border-left-color: var(--blue); }
.band-strong .band-letter { color: var(--blue); }
.band-strong .band-badge { background: var(--blue); }
.band-good { background: #f1f5f9; border-left-color: #5b6b7c; }
.band-good .band-letter { color: #41505f; }
.band-good .band-badge { background: #5b6b7c; }
.band-satisfactory { background: var(--amber-soft); border-left-color: var(--amber); }
.band-satisfactory .band-letter { color: var(--amber); }
.band-satisfactory .band-badge { background: var(--amber); }
.band-attention { background: #fdeee3; border-left-color: #c2410c; }
.band-attention .band-letter { color: #c2410c; }
.band-attention .band-badge { background: #c2410c; }
.band-action { background: #fdeeee; border-left-color: #b3261e; }
.band-action .band-letter { color: #b3261e; }
.band-action .band-badge { background: #b3261e; }

/* ---------- Generic content card grids ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
  gap: 1rem;
  margin: 1.25rem 0 0.5rem;
}
.mini-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.05rem 1.15rem;
  box-shadow: var(--shadow);
}
.mini-card h3 { margin-top: 0; }
.mini-card p:last-child, .mini-card ul:last-child, .mini-card ol:last-child { margin-bottom: 0; }
.mini-card ul, .mini-card ol { margin: 0; padding-left: 1.2rem; }
.stack-cards { display: grid; gap: 1rem; margin: 1.25rem 0 0.5rem; }
.step-num.bad { background: #b3261e; }
.formula {
  background: var(--blue-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  text-align: center;
  font-size: 1.08rem;
  margin: 0 0 1rem;
}
.tier-num {
  display: block;
  font-size: 2rem; font-weight: 800; line-height: 1.1;
  color: var(--blue);
  margin-bottom: 0.25rem;
}
.grade-chip {
  display: inline-block;
  background: var(--blue); color: #fff;
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.02em;
  padding: 0.16rem 0.65rem; border-radius: 999px;
  margin-right: 0.55rem;
  vertical-align: 0.12em;
}

/* ---------- Narrow screens ---------- */
@media (max-width: 640px) {
  .course-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .course-row .field-name { grid-column: 1 / -1; }
  .btn-remove { grid-column: 1 / -1; }
  .content-section { padding: 1.1rem; }
  .calc-card { padding: 1rem; }
  .steps-grid { grid-template-columns: minmax(0, 1fr); }
  .compare-grid { grid-template-columns: minmax(0, 1fr); }
  .card-grid { grid-template-columns: minmax(0, 1fr); }

  /* Stacked table cards with injected labels */
  .table-scroll { overflow-x: visible; }
  table.stacked { min-width: 0; }
  table.stacked thead { position: absolute; left: -9999px; top: -9999px; }
  table.stacked tbody tr { display: block; border-top: 1px solid var(--line); padding: 0.4rem 0; }
  table.stacked tbody td {
    display: flex; justify-content: space-between; gap: 1rem;
    border-top: none; padding: 0.35rem 0.9rem;
  }
  table.stacked tbody td::before {
    content: attr(data-label);
    font-weight: 600; color: var(--blue-dark);
  }
}

/* ---------- Print: result only ---------- */
@media print {
  .site-header, .site-nav, .site-footer, .calc-controls, .calc-actions,
  .preset-row, .course-rows, .content-section, .hero .sub, .btn-remove { display: none !important; }
  body { background: #fff; }
  .calc-card, .result-panel { box-shadow: none; border: 1px solid #999; }
  .result-panel { background: #fff; color: #000; }
  .result-panel .result-gpa, .result-panel .result-stat { color: #000; }
  .result-panel .result-label, .result-panel .result-note { color: #333; }
  .result-panel .result-verdict { color: #000; }
}
