/* =========================
   Design Tokens
========================= */

:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-soft: #13161c;
  --border: #262b36;
  --border-soft: #2d3442;
  --input-bg: #111318;
  --hover: #1d2330;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.22);

  --text: #f3f4f6;
  --muted: #9ca3af;
  --muted-2: #c7cbd1;

  --mechanical: #60a5fa;
  --electrical: #39ab63;
  --public-health: #f28b82;
  --accent-neutral: #e5c07b;
}

/* =========================
   Base / Reset
========================= */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

body {
  min-height: 100vh;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

/* =========================
   Shared Layout
========================= */

.layout {
  display: flex;
  min-height: 100vh;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 40px 32px 56px;
}

.main-inner {
  max-width: 1040px;
  margin: 0 auto;
}

.section {
  margin-bottom: 28px;
}

.section-title {
  margin: 0 0 14px 0;
  font-size: 13px;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--muted);
}

/* =========================
   Sidebar
========================= */

#sidebar-container {
  width: 300px;
  min-width: 300px;
  flex-shrink: 0;
  background: var(--panel-soft);
  border-right: 1px solid var(--border);
  opacity: 0;
  transition: opacity 0.12s ease;
}

#sidebar-container.sidebar-ready {
  opacity: 1;
}

.sidebar {
  width: 100%;
  background: var(--panel-soft);
  padding: 28px 20px 32px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-brand {
  margin-bottom: 26px;
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sidebar-logo {
  width: 52px;
  height: auto;
  flex-shrink: 0;
}

.sidebar-brand-text h1 {
  margin: 0 0 4px 0;
  font-size: 28px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-brand-text p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.sidebar-search {
  width: 100%;
  margin-bottom: 26px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.sidebar-search::placeholder {
  color: var(--muted);
}

.sidebar-search:focus {
  outline: none;
  background: #151922;
}

body.mechanical .sidebar-search:focus {
  border-color: var(--mechanical);
}

body.electrical .sidebar-search:focus {
  border-color: var(--electrical);
}

body.public-health .sidebar-search:focus {
  border-color: var(--public-health);
}

.nav-group {
  margin-bottom: 24px;
}

.nav-group h2 {
  margin: 0 0 6px 0;
  font-size: 14px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.nav-group.mechanical h2 {
  color: var(--mechanical);
}

.nav-group.electrical h2 {
  color: var(--electrical);
}

.nav-group.public-health h2 {
  color: var(--public-health);
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.nav-subheading {
  margin: 14px 12px 4px;
  font-size: 12px;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #8b93a5;
  font-weight: 700;
}

.nav-links a,
.nav-links span {
  display: block;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.3;
  color: var(--muted-2);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Sidebar hover colours by discipline */
.nav-group.mechanical .nav-links a:hover {
  background: rgba(96, 165, 250, 0.14);
  border-color: rgba(96, 165, 250, 0.35);
  color: #ffffff;
}

.nav-group.electrical .nav-links a:hover {
  background: rgba(57, 171, 99, 0.14);
  border-color: rgba(57, 171, 99, 0.35);
  color: #ffffff;
}

.nav-group.public-health .nav-links a:hover {
  background: rgba(242, 139, 130, 0.14);
  border-color: rgba(242, 139, 130, 0.35);
  color: #ffffff;
}

.nav-links a.active {
  color: #ffffff;
}

body.mechanical .nav-links a.active {
  background: rgba(96, 165, 250, 0.18);
  border-color: rgba(96, 165, 250, 0.28);
}

body.electrical .nav-links a.active {
  background: rgba(57, 171, 99, 0.18);
  border-color: rgba(57, 171, 99, 0.28);
}

body.public-health .nav-links a.active {
  background: rgba(242, 139, 130, 0.18);
  border-color: rgba(242, 139, 130, 0.28);
}

.nav-links .disabled {
  color: var(--muted);
  opacity: 0.55;
  cursor: default;
}

/* =========================
   Homepage
========================= */

.hero {
  margin-bottom: 28px;
  padding: 34px;
  background: linear-gradient(180deg, #171a21 0%, #13161c 100%);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero-top {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.hero-logo {
  width: 84px;
  height: auto;
  flex-shrink: 0;
}

.hero-title-wrap h1 {
  margin: 0 0 8px 0;
  font-size: 42px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.hero-title-wrap p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.hero-tagline {
  max-width: 820px;
  margin: 0 0 14px 0;
  font-size: 24px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero-support {
  max-width: 860px;
  margin: 0;
  color: var(--muted-2);
  font-size: 16px;
  line-height: 1.7;
}

.discipline-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.discipline-card {
  height: 100%;
  padding: 22px 20px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.discipline-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-soft);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
}

.discipline-card h3 {
  margin: 0 0 8px 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.discipline-card.mechanical h3 {
  color: var(--mechanical);
}

.discipline-card.electrical h3 {
  color: var(--electrical);
}

.discipline-card.public-health h3 {
  color: var(--public-health);
}

.discipline-card p {
  margin: 0 0 14px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.card-subheading {
  margin: 18px 0 8px;
  font-size: 13px;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: #8b93a5;
}

.card-subheading:first-of-type {
  margin-top: 8px;
}

.discipline-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.discipline-card ul + .card-subheading {
  margin-top: 20px;
}

.discipline-card li {
  margin-bottom: 9px;
}

.discipline-card li:last-child {
  margin-bottom: 0;
}

.discipline-card a,
.discipline-card span {
  font-size: 15px;
  line-height: 1.4;
  color: #ffffff;
}

.discipline-card a {
  transition: opacity 0.2s ease;
}

.discipline-card a:hover {
  opacity: 0.78;
}

.discipline-card .disabled {
  color: var(--muted);
  opacity: 0.65;
  cursor: default;
}

.site-note {
  margin-top: 8px;
  padding: 18px 20px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

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

.site-footer {
  margin-top: 28px;
  padding: 18px 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.site-footer p {
  margin: 0;
}

.footer-links {
  margin-top: 6px;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--muted);
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.footer-links a:hover {
  color: #ffffff;
  text-decoration: underline;
}

/* =========================
   Calculator / Page Shell
========================= */

.page-header {
  margin-bottom: 28px;
}

.discipline-label {
  margin: 0 0 18px 0;
  font-size: 14px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.discipline-label.mechanical {
  color: var(--mechanical);
}

.discipline-label.electrical {
  color: var(--electrical);
}

.discipline-label.public-health {
  color: var(--public-health);
}

.page-header h1 {
  margin: 0 0 16px 0;
  font-size: 48px;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.page-description {
  max-width: 720px;
  margin: 0;
  color: var(--muted-2);
  font-size: 18px;
  line-height: 1.6;
}

.intro-note {
  margin-top: 14px;
  max-width: 760px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.calc-card,
.content-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.calc-card {
  padding: 28px;
  margin-bottom: 18px;
}

.content-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
  margin-bottom: 18px;
  text-align: left;
}

.content-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20px;
  bottom: 20px;
  width: 3px;
  border-radius: 2px;
  opacity: 0.55;
  background: #3b4455;
}

.content-card p {
  margin: 0 0 14px 0;
  color: var(--muted-2);
  font-size: 15px;
  line-height: 1.7;
}

.content-card p:last-child {
  margin-bottom: 0;
}

.content-card strong {
  color: #ffffff;
}

/* =========================
   Content Section Heading Colours
========================= */

/* Neutral headings (About, Contact, etc.) */
body:not(.mechanical):not(.electrical):not(.public-health) .content-card .section-title {
  color: var(--accent-neutral);
}

body.mechanical .content-card .section-title {
  color: var(--mechanical);
}

body.electrical .content-card .section-title {
  color: var(--electrical);
}

body.public-health .content-card .section-title {
  color: var(--public-health);
}

body.mechanical .content-card::before {
  background: var(--mechanical);
}

body.electrical .content-card::before {
  background: var(--electrical);
}

body.public-health .content-card::before {
  background: var(--public-health);
}

/* =========================
   Forms and Inputs
========================= */

.form-group {
  margin-bottom: 22px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 10px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.4;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 16px 18px;
  background: var(--input-bg);
  border: 1px solid #3a404d;
  border-radius: 10px;
  color: #ffffff;
  font-size: 16px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  background: #151922;
}

body.mechanical .form-group input:focus,
body.mechanical .form-group select:focus,
body.mechanical .form-group textarea:focus {
  border-color: var(--mechanical);
}

body.electrical .form-group input:focus,
body.electrical .form-group select:focus,
body.electrical .form-group textarea:focus {
  border-color: var(--electrical);
}

body.public-health .form-group input:focus,
body.public-health .form-group select:focus,
body.public-health .form-group textarea:focus {
  border-color: var(--public-health);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.input-note {
  display: block;
  margin-top: -12px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.unit-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.hidden {
  display: none;
}

.input-method-card {
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--input-bg);
}

.input-method-title {
  margin-bottom: 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
  font-size: 15px;
}

.radio-option input {
  width: auto;
  margin: 0;
}

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

.button-row {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.calc-button {
  width: 100%;
  margin-bottom: 24px;
  padding: 14px 18px;
  background: #f3f4f6;
  border: none;
  border-radius: 10px;
  color: #111318;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.button-row .calc-button {
  margin-bottom: 0;
}

.calc-button:hover {
  opacity: 0.9;
}

.secondary-button {
  width: 100%;
  padding: 14px 18px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.secondary-button:hover {
  background: var(--hover);
  border-color: #374151;
}

/* =========================
   Results
========================= */

.result-box {
  padding: 24px;
  background: var(--input-bg);
  border: 1px solid #3a404d;
  border-radius: 16px;
  text-align: left;
}

.result-label {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.result-value {
  font-weight: 700;
}

.result-value-main {
  margin-bottom: 8px;
  font-size: 34px;
  line-height: 1.1;
  font-weight: 700;
}

.result-value-secondary {
  color: var(--muted-2);
  font-size: 16px;
  line-height: 1.4;
}

.result-extra {
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted-2);
}

/* =========================
   Method / Reference / Notes
========================= */

.method-list,
.reference-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted-2);
  font-size: 15px;
  line-height: 1.7;
}

.method-list li,
.reference-list li {
  margin-bottom: 8px;
}

.method-list li:last-child,
.reference-list li:last-child {
  margin-bottom: 0;
}

.formula-block {
  margin: 14px 0 18px;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  font-size: 17px;
  line-height: 1.6;
  color: #ffffff;
}

.design-note {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--muted-2);
  font-size: 14px;
  line-height: 1.7;
}

.method-result {
  font-weight: 700;
}

/* =========================
   Discipline Colour Overrides
========================= */

body.mechanical .result-value-main,
body.mechanical .method-result {
  color: var(--mechanical);
}

body.electrical .result-value-main,
body.electrical .method-result {
  color: var(--electrical);
}

body.public-health .result-value-main,
body.public-health .method-result {
  color: var(--public-health);
}

/* =========================
   Related Links
========================= */

.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.related-links a {
  display: inline-block;
  padding: 11px 14px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #ffffff;
  font-size: 14px;
  line-height: 1.3;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.related-links a:hover {
  background: var(--hover);
  border-color: #374151;
}

/* =========================
   Responsive
========================= */

@media (max-width: 1100px) {
  .discipline-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }

  #sidebar-container {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar {
    height: auto;
    position: relative;
    border-bottom: 1px solid var(--border);
  }

  .main {
    padding: 24px 18px 40px;
  }

  .hero {
    padding: 28px 22px;
  }

  .hero-top {
    align-items: flex-start;
  }

  .hero-title-wrap h1 {
    font-size: 34px;
  }

  .hero-tagline {
    font-size: 21px;
  }

  .page-header h1 {
    font-size: 40px;
  }
}

@media (max-width: 700px) {
  .button-row {
    flex-direction: column;
  }

  .result-value-main {
    font-size: 26px;
  }
}

@media (max-width: 600px) {
  .hero-top {
    flex-direction: column;
  }

  .hero-logo {
    width: 72px;
  }

  .hero-title-wrap h1 {
    font-size: 30px;
  }

  .hero-tagline {
    font-size: 19px;
  }

  .hero-support,
  .page-description,
  .content-card p,
  .intro-note {
    font-size: 15px;
  }

  .page-header h1 {
    font-size: 34px;
  }

  .form-group label,
  .form-group input,
  .form-group select,
  .form-group textarea,
  .result-box p,
  .calc-button,
  .secondary-button {
    font-size: 15px;
  }
}