:root {
  --primary-color: #005d9b;
  --secondary-color: #d0021b;
  --background-color: #f5f5f5;
  --text-color: #333333;
  --white: #ffffff;
  --overlay-color: rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--background-color);
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1rem;
}

a {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

@media (max-width: 768px) {
  .container {
    padding: 0 0;
  }
}

.header {
  background-color: var(--white);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 1000;
  padding: 0 1rem;
}

.header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 64px;
}

.logo {
  font-size: clamp(0.95rem, 3.2vw, 1.2rem);
  font-weight: 700;
  color: var(--primary-color);
  text-decoration: none;
  padding: 1rem 0;
  display: inline-block;
  line-height: 1.3;
  max-width: calc(100% - 4rem);
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.75rem;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  flex-shrink: 0;
}

.hamburger-line {
  display: block;
  width: 25px;
  height: 2px;
  background-color: var(--text-color);
  margin: 3px 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--overlay-color);
  z-index: 999;
  display: none;
}

.overlay.active {
  display: block;
}

@media (max-width: 768px) {
  .hamburger {
    display: inline-flex;
  }

  .hamburger.active .hamburger-line:nth-child(1) {
    transform: translateY(5px) rotate(45deg);
  }

  .hamburger.active .hamburger-line:nth-child(2) {
    opacity: 0;
  }

  .hamburger.active .hamburger-line:nth-child(3) {
    transform: translateY(-5px) rotate(-45deg);
  }
}

/* Footer */
.footer {
  background-color: var(--white);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding: 2rem 1rem;
  margin-top: auto;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
}

.copyright {
  font-size: 0.9rem;
  color: var(--text-color);
}

.privacy-link {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.3s ease;
  padding: 0.35rem 0.25rem;
  display: inline-block;
  line-height: 1.4;
}

.privacy-link:hover,
.privacy-link:focus {
  opacity: 0.85;
}

.privacy-link[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;
}

.footer-nav {
  display: flex;
  gap: 0.75rem 1.25rem;
  align-items: center;
  flex-wrap: wrap;
}

.go-top {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background-color: var(--primary-color);
  color: var(--white);
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  z-index: 998;
}

.go-top:hover,
.go-top:focus {
  background-color: #004b7d;
}

.go-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (max-width: 768px) {
  .footer-content {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }

  .footer-nav {
    justify-content: center;
    gap: 0.5rem 1rem;
  }

  .go-top {
    bottom: 0.875rem;
    right: 0.875rem;
    width: 2.5rem;
    height: 2.5rem;
  }
}

@media (max-width: 480px) {
  .footer {
    padding: 1.5rem 0.75rem;
  }

  .copyright {
    font-size: 0.85rem;
  }

  .privacy-link {
    font-size: 0.95rem;
  }

  .footer-nav {
    gap: 0.4rem 0.85rem;
  }
}

/* Hero Section */
.hero {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem 1rem 1rem 1rem;
}

.hero-content {
  max-width: 600px;
}

.hero-heading {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-color);
}

.hero-subheading {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--primary-color);
}

.hero-text {
  margin-top: 0.5rem;
  color: var(--text-color);
}

/* Calculator Section */
.calculator-section {
  padding: 2rem 0;
}

.calculator-section .calculator {
  max-width: 600px;
  margin: 0 auto;
}

.calculator {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  padding: 2rem;
}

.calculator-heading {
  color: var(--primary-color);
  text-align: center;
  margin-bottom: 1.5rem;
}

.input-group {
  margin-bottom: 1.5rem;
}

.input-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-color);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-unit {
  position: absolute;
  right: 1rem;
  color: var(--secondary-color);
  font-weight: 500;
  pointer-events: none;
}

input[type="number"] {
  width: 100%;
  padding: 0.8rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

input[type="number"]:focus {
  border-color: var(--primary-color);
  outline: none;
}

.radio-group {
  display: flex;
  gap: 1.5rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.unit-toggle {
  display: inline-flex;
  background: var(--background-color);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.unit-btn {
  padding: 0.5rem 2rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-color);
}

.unit-btn.active {
  background: var(--primary-color);
  color: white;
  border-radius: 6px;
}

.results-card {
  margin-top: 2rem;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
  flex-wrap: wrap;
}

.result-label {
  color: var(--text-color);
  font-weight: 600;
}

.result-value {
  color: var(--primary-color);
  font-weight: 700;
  font-size: 1.1rem;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
  padding: 1rem 2rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: opacity 0.3s ease;
  width: 100%;
}

.btn-primary:hover {
  opacity: 0.9;
}

@media (max-width: 768px) {
  .calculator-section {
    padding: 1rem;
  }

  .calculator {
    padding: 1rem;
  }
}

/* Calculator Enhancements */
.custom-select {
  width: 100%;
  padding: 0.8rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  appearance: none;
  background: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232a9d8f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") no-repeat right 1rem center/1rem;
}

.dual-input {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.dual-input select {
  width: 100%;
  padding: 0.8rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
}

.input-group small {
  display: block;
  color: #666;
  font-size: 0.8em;
  margin-top: 0.25rem;
}

.results-heading {
  color: var(--primary-color);
  text-align: center;
  margin-bottom: 1.5rem;
}

.hidden {
  display: none !important;
}

.error-message {
  color: #dc3545;
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: none;
}

.input-group.invalid input,
.input-group.invalid select {
  border-color: #dc3545;
}

.input-group.invalid .error-message {
  display: block;
}

.weightloss,
.new-weight {
  background-color: #eee;
  padding: 0 1rem;
  font-size: 0.8rem;
}

.weightloss .result-value,
.new-weight .result-value {
  font-size: 0.8rem;
}

/* Content Section */
.content {
  max-width: 1000px;
  padding: 2rem 1rem;
}

.content ol,
.content ul {
  margin: 1rem 0 1rem 1.5rem;
}

.content img {
  max-width: 500px;
  height: auto;
  display: block;
  margin: 1rem auto;
  border: 1px solid var(--primary-color);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

@media (max-width: 768px) {
  .content img {
    width: 100%;
  }
}

/* Combined Navigation */
.nav {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: -100%;
  width: 82%;
  max-width: 320px;
  height: 100%;
  background-color: var(--white);
  z-index: 1001;
  transition: left 0.3s ease;
  padding: 4rem 0 2rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
}

.nav.active {
  left: 0;
}

.nav-list {
  list-style: none;
  padding: 0 1.25rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.85rem 1rem;
  min-height: 44px;
  text-decoration: none;
  color: var(--text-color);
  border-radius: 6px;
  font-size: 1.05rem;
  font-weight: 500;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.nav-link:hover,
.nav-link:focus {
  background-color: var(--background-color);
  color: var(--primary-color);
}

.nav-link[aria-current="page"] {
  color: var(--primary-color);
  font-weight: 600;
  background-color: rgba(0, 93, 155, 0.08);
}

@media (min-width: 769px) {
  .nav {
    position: static;
    flex-direction: row;
    width: auto;
    max-width: none;
    height: auto;
    background-color: transparent;
    padding: 0;
    overflow: visible;
    box-shadow: none;
  }

  .nav-list {
    display: flex;
    flex-direction: row;
    gap: 2rem;
    padding: 0;
  }

  .nav-link {
    padding: 1rem 0;
    min-height: 0;
    background-color: transparent;
    border-radius: 0;
    font-size: 1rem;
  }

  .nav-link:hover,
  .nav-link:focus {
    background-color: transparent;
    color: var(--primary-color);
  }

  .nav-link[aria-current="page"] {
    background-color: transparent;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: calc(1rem - 2px);
  }

  .hamburger {
    display: none;
  }

  .overlay {
    display: none;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 0 0.75rem;
  }

  .header .container {
    min-height: 56px;
  }

  .nav {
    width: 86%;
  }

  .nav-list {
    padding: 0 1rem;
  }
}

/* Keyboard focus rings for header & footer interactive elements */
.logo:focus-visible,
.nav-link:focus-visible,
.hamburger:focus-visible,
.privacy-link:focus-visible,
.go-top:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {

  .nav,
  .hamburger-line,
  .nav-link,
  .privacy-link,
  .go-top,
  .overlay {
    transition: none !important;
  }
}

/* Fieldset Styles */
fieldset {
  border: 2px solid var(--primary-color);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

legend {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary-color);
  padding: 0 0.5rem;
  text-transform: uppercase;
}

@media (max-width: 768px) {
  fieldset {
    padding: 1rem;
  }
}

/* Info-section */
.info-section {
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.info-section h2 {
  font-size: 1.5rem;
  color: var(--primary-color);
  margin-top: 1rem;
}

.info-section p {
  font-size: 1rem;
  color: var(--text-color);
  margin-bottom: 1rem;
}

.info-section ul,
.info-section ol {
  margin: 1rem 0;
  margin-left: 2rem;
  margin-bottom: 1rem;
}

.info-section ul li,
.info-section ol li {
  margin-bottom: 0.5rem;
}

.info-section img {
  max-width: 100%;
  height: auto;
  margin: 1rem 0;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* References */
.references-links li {
  word-wrap: break-word;
}

/* author-section */
.author-section {
  padding: 1rem;
  margin: 2rem 0;
  background-color: var(--white);
}

.author-section h2 {
  font-size: 1.5rem;
  color: var(--primary-color);
  margin-top: 1rem;
}

.author-section p {
  font-size: 1rem;
  color: var(--text-color);
  margin-bottom: 1rem;
}

.author-section img {
  max-width: 100%;
  height: auto;
  margin: 1rem 0;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.author-section ol,
.author-section ul {
  margin: 1rem 0;
  margin-left: 2rem;
  margin-bottom: 1rem;
}

.author-section ul li {
  margin-bottom: 0.5rem;
}

/* Responsive table styling for .info-section */
.info-section .info-table-wrapper {
  margin: 1rem 0;
}

.info-section .table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.info-section .table-scroll:focus {
  outline: 3px solid rgba(0,93,155,0.15);
  outline-offset: 4px;
}

.info-section .table-scroll table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  min-width: 600px; /* ensures horizontal scroll on small screens */
}

.info-section table th,
.info-section table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  text-align: left;
  vertical-align: top;
  color: var(--text-color);
}

.info-section table th {
  font-weight: 700;
  color: var(--primary-color);
  background: linear-gradient(180deg, rgba(0,0,0,0.02), transparent);
}

.info-section table caption {
  caption-side: top;
  text-align: left;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

@media (max-width: 768px) {
  .info-section .table-scroll table {
    min-width: 480px;
  }

  .info-section table th,
  .info-section table td {
    padding: 0.45rem 0.5rem;
    font-size: 0.95rem;
  }
}

/* Small visual improvement for zebra rows */
.info-section table tbody tr:nth-child(odd) {
  background-color: rgba(0,0,0,0.02);
}