/* =========================================================
   Reset & Base Styles
   ========================================================= */

html,
body {
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  background-color: #F5F5F5;
  color: #333333;
  min-height: 100vh;
  box-sizing: border-box;
  overflow-x: hidden;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

html {
  scroll-behavior: smooth;
}

body {
  line-height: 1.5;
}

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

a {
  color: inherit;
}

a:focus,
button:focus,
input:focus,
.toggle-label:focus {
  outline: 3px solid #777777;
  outline-offset: 3px;
}

/* =========================================================
   Header & Navigation
   ========================================================= */

header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 70px;
  background-color: #FFFFFF;
  color: #000000;
  padding: 0 20px;
  z-index: 2000;
  border-bottom: 2px solid #000000;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  height: 100%;
  max-width: 260px;
  flex-shrink: 0;
}

.logo img {
  display: block;
  height: auto;
  max-height: 44px;
  width: auto;
  object-fit: contain;
}

.logo-desktop {
  display: block !important;
  max-width: 240px;
}

.logo-mobile {
  display: none !important;
  max-width: 170px;
}

/* Desktop Navigation */
nav {
  height: 100%;
}

nav > ul#nav-menu {
  display: flex;
  gap: 20px;
  list-style: none;
  margin: 0;
  padding: 0 20px;
  height: 100%;
  align-items: center;
  overflow-x: auto;
  color: #000000;
  background-color: transparent;
}

nav > ul#nav-menu a {
  display: inline-flex;
  align-items: center;
  padding: 0.75em 1em;
  font-size: 1.125rem;
  color: #000000;
  text-decoration: none;
  border-radius: 6px;
  transition: background-color 0.3s;
  white-space: nowrap;
}

nav > ul#nav-menu a:hover,
nav > ul#nav-menu a:focus {
  background-color: #EAEAEA;
  color: #000000;
}

/* Hamburger Button */
#hamburger {
  display: none;
  position: fixed;
  top: 18px;
  right: 20px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 2100;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

#hamburger span {
  width: 100%;
  height: 4px;
  background: #000000;
  border-radius: 2px;
}

/* =========================================================
   Ads
   ========================================================= */

.mobile-top-ad {
  display: none !important;
}

.mobile-result-ad {
  display: none;
}

.advertisement {
  width: 300px;
  min-height: 600px;
  align-self: stretch;
  background-color: transparent;

  display: flex;
  align-items: flex-start;
  justify-content: center;
  text-align: center;

  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
}

.advertisement iframe,
.mobile-top-ad iframe,
.mobile-result-ad iframe,
.advertisement ins,
.mobile-top-ad ins,
.mobile-result-ad ins,
.advertisement img,
.mobile-top-ad img,
.mobile-result-ad img {
  display: block;
  margin: 0 auto;
}

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

main {
  margin-top: 70px;
  padding: 40px 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 60px;
  flex-wrap: wrap;
}

/* =========================================================
   Hero Section
   ========================================================= */

.hero {
  width: 100%;
  max-width: 860px;
  margin: 0 auto 10px;
  text-align: center;
  flex: 0 0 100%;
}

.hero h1 {
  font-size: clamp(2.3rem, 5vw, 4.25rem);
  line-height: 1.1;
  margin: 0 0 14px;
  color: #222222;
}

.hero p {
  max-width: 760px;
  margin: 0 auto;
  font-size: 1.15rem;
  line-height: 1.7;
  color: #444444;
}

/* =========================================================
   Calculator Panel
   ========================================================= */

.calculator {
  background-color: #FFFFFF;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 500px;
}

.section-title {
  font-size: 2.5em;
  margin: 0 0 20px;
  text-align: center;
  line-height: 1.15;
}

.calculator-intro {
  font-size: 1rem;
  line-height: 1.6;
  color: #555555;
  text-align: center;
  margin: -5px 0 20px;
}

label {
  display: block;
  margin: 15px 0 5px;
  font-size: 18px;
}

input[type="number"] {
  width: 100%;
  padding: 14px;
  font-size: 18px;
  border: 1px solid #B0B0B0;
  border-radius: 6px;
  margin-bottom: 20px;
  background-color: #FFFFFF;
  color: #333333;
}

input[type="number"]:focus {
  border-color: #333333;
}

.height-wrapper {
  display: flex;
  gap: 50px;
  margin-bottom: 20px;
}

.height-field {
  flex: 1;
}

.unit-toggle {
  display: flex;
  border: 1px solid #B0B0B0;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 20px;
}

.toggle-label {
  flex: 1;
  text-align: center;
  padding: 16px 0;
  font-size: 18px;
  cursor: pointer;
  background-color: #F5F5F5;
  color: #4A4A4A;
  transition: background-color 0.3s;
  user-select: none;
}

.toggle-label:hover {
  background-color: #E5E5E5;
}

.toggle-label.active {
  background-color: #333333;
  color: #FFFFFF;
}

.info {
  display: inline-block;
  background-color: #DDDDDD;
  color: #333333;
  border-radius: 50%;
  padding: 2px 6px;
  margin-left: 5px;
  font-size: 0.8em;
  position: relative;
  cursor: help;
}

.info:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: 125%;
  transform: translateX(-50%);
  background-color: #4A4A4A;
  color: #FFFFFF;
  padding: 6px 12px;
  border-radius: 4px;
  white-space: normal;
  line-height: 1.4;
  z-index: 1002;
  width: 220px;
  font-size: 0.9rem;
  font-weight: normal;
}

.info:hover::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 115%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: #4A4A4A transparent transparent transparent;
  z-index: 1001;
}

.calc-btn {
  width: 100%;
  padding: 16px;
  font-size: 20px;
  font-weight: bold;
  background-color: #333333;
  color: #FFFFFF;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.calc-btn:hover {
  background-color: #4A4A4A;
}

.clear-btn {
  display: none;
  width: 100%;
  padding: 16px;
  font-size: 18px;
  background-color: #AAAAAA;
  color: #FFFFFF;
  border: none;
  border-radius: 6px;
  margin-top: 10px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.clear-btn:hover {
  background-color: #888888;
}

.error-message {
  display: none;
  color: #B00020;
  background-color: #FFE5E5;
  border: 1px solid #B00020;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 1.125rem;
  font-weight: bold;
  border-radius: 4px;
}

.result {
  margin-top: 25px;
  text-align: center;
}

.result-intro {
  font-size: 1.25rem;
  font-weight: bold;
  margin-bottom: 8px;
}

.main-size {
  font-size: 3em;
  font-weight: bold;
  margin-bottom: 0.25em;
}

.result-explanation {
  max-width: 420px;
  margin: 0 auto 14px;
  font-size: 1rem;
  line-height: 1.6;
}

.size-standards small {
  display: block;
  line-height: 1.4;
}

.tailoring-notes {
  margin-top: 16px;
  padding: 14px;
  background-color: #F5F5F5;
  border: 1px solid #DADADA;
  border-radius: 6px;
  text-align: left;
}

.tailoring-notes ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

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

.suit-sizing-guide,
.measurement-guide,
.faq-section {
  background-color: #FFFFFF;
  border: 1px solid #B0B0B0;
  border-radius: 8px;
  padding: 34px;
  margin: 30px auto 60px;
  max-width: 900px;
}

.suit-sizing-guide h2,
.measurement-guide h2,
.faq-section h2 {
  font-size: 2.25em;
  line-height: 1.2;
  margin: 0 0 20px;
  text-align: center;
}

.suit-sizing-guide h2:not(:first-child),
.measurement-guide h2:not(:first-child),
.faq-section h2:not(:first-child) {
  margin-top: 40px;
}

.suit-sizing-guide h3,
.measurement-guide h3,
.faq-section h3 {
  font-size: 1.55em;
  line-height: 1.25;
  margin-top: 30px;
  margin-bottom: 10px;
}

.suit-sizing-guide p,
.measurement-guide p,
.faq-section p,
.suit-sizing-guide li {
  font-size: 18px;
  line-height: 1.65;
}

.suit-sizing-guide ul {
  margin: 14px 0 28px;
  padding-left: 24px;
}

.suit-sizing-guide li {
  margin-bottom: 8px;
}

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

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  margin: 20px 0 34px;
  border: 1px solid #D0D0D0;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background-color: #FFFFFF;
  min-width: 720px;
}

thead {
  background-color: #333333;
  color: #FFFFFF;
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid #DADADA;
  font-size: 1rem;
}

tbody tr:nth-child(even) {
  background-color: #F7F7F7;
}

tbody tr:hover {
  background-color: #EEEEEE;
}

/* =========================================================
   Example Cards
   ========================================================= */

.example-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.example-grid article {
  background-color: #F7F7F7;
  border: 1px solid #DADADA;
  border-radius: 8px;
  padding: 20px;
}

.example-grid h3 {
  font-size: 1.2rem;
  margin-top: 0;
}

.example-grid p {
  font-size: 1rem;
  margin-bottom: 0;
}

/* =========================================================
   Measurement Guide
   ========================================================= */

.diagram-placeholder {
  display: block;
  width: 100%;
  max-width: 420px;
  margin: 0 auto 30px;
  border: 3px dashed #B0B0B0;
  border-radius: 6px;
  box-sizing: border-box;
  overflow: hidden;
}

.diagram-placeholder img {
  display: block;
  width: 100%;
  height: auto;
}

/* =========================================================
   FAQ
   ========================================================= */

.faq-section article {
  padding: 20px 0;
  border-bottom: 1px solid #E2E2E2;
}

.faq-section article:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.faq-section h3 {
  margin-top: 0;
}

/* =========================================================
   Other Calculator Tools
   ========================================================= */

.other-calculators {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  padding: 0 20px;
  max-width: 960px;
  margin: 60px auto;
}

.other-calculators h2 {
  width: 100%;
  font-size: 2.2em;
  line-height: 1.2;
  margin: 0 0 20px;
  text-align: center;
}

.other-calculators .calc-card {
  flex: 0 0 260px;
  min-height: 260px;
  background-color: #FFFFFF;
  border: 1px solid #B0B0B0;
  border-radius: 8px;
  padding: 34px 30px 18px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  box-sizing: border-box;
  color: #333333;
  font-size: 20px;
  text-decoration: none;
  transition: background-color 0.3s, box-shadow 0.3s, transform 0.2s;
  white-space: normal;
  overflow-wrap: break-word;
}

.other-calculators .calc-card:hover,
.other-calculators .calc-card:focus {
  background-color: #E8E8E8;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}

.other-calculators .calc-card img {
  margin-bottom: 14px;
}

.calc-card-title {
  font-weight: bold;
  line-height: 1.3;
}

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

footer {
  background-color: #4A4A4A;
  color: #FFFFFF;
  padding: 30px 20px;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  margin-bottom: 20px;
  gap: 20px;
}

.footer-links .column {
  flex: 1;
  min-width: 180px;
  margin: 10px;
}

.footer-links h2,
.footer-links h3 {
  margin-top: 0;
  font-size: 1.25rem;
}

.footer-links ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-links li {
  margin-bottom: 7px;
}

.footer-links a {
  color: #FFFFFF;
  text-decoration: none;
}

.footer-links a:hover,
.footer-links a:focus {
  text-decoration: underline;
}

footer p {
  margin-bottom: 0;
}

/* =========================================================
   Tablet & Mobile Layout
   ========================================================= */

@media (max-width: 901px) {
  main {
    margin-top: 70px;
    padding: 24px 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
  }

  .hero {
    order: 0;
    margin-bottom: 0;
  }

  .calculator {
    order: 1;
  }

  .mobile-result-ad {
    order: 2;
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    max-width: 500px;
    aspect-ratio: 1 / 1;
    height: auto;
    margin: 0 auto;

    border: none;
    border-radius: 0;
    padding: 0;
    background-color: transparent;
    text-align: center;
    overflow: hidden;
  }

  .mobile-result-ad img,
  .mobile-result-ad iframe,
  .mobile-result-ad ins {
    max-width: 100% !important;
    height: auto !important;
    display: block;
    margin: 0 auto;
  }

  .advertisement {
    display: none;
  }

  .example-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   Mobile Navigation + Logo Swap
   ========================================================= */

@media (max-width: 768px) {
  .logo {
    max-width: 190px;
  }

  .logo-desktop {
    display: none !important;
  }

  .logo-mobile {
    display: block !important;
    max-width: 160px;
  }

  #hamburger {
    display: flex;
  }

  nav > ul#nav-menu {
    display: none;
  }

  #nav-menu {
    display: none;
  }

  #nav-menu.active {
    display: flex;
    position: fixed;
    top: 70px;
    right: 0;
    width: 260px;
    background: rgba(51,51,51,0.95);
    border-radius: 0 0 0 8px;
    box-shadow: -2px 2px 8px rgba(0,0,0,0.2);
    flex-direction: column;
    padding: 10px 0;
    max-height: none !important;
    overflow-y: visible !important;
    z-index: 1999;
    animation: slideIn 0.3s ease-out forwards;
  }

  @keyframes slideIn {
    from {
      transform: translateX(100%);
    }

    to {
      transform: translateX(0);
    }
  }

  #nav-menu.active li {
    width: 100%;
  }

  #nav-menu.active li a {
    display: block;
    width: 100%;
    padding: 15px 20px;
    color: #FFFFFF;
    text-decoration: none;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 0.5px;
    transition: background 0.2s;
    box-sizing: border-box;
  }

  #nav-menu.active li:not(:last-child) a {
    border-bottom: 1px solid rgba(255,255,255,0.2);
  }

  #nav-menu.active li a:hover,
  #nav-menu.active li a:focus {
    background: rgba(255,255,255,0.1);
    color: #FFFFFF;
  }

  .suit-sizing-guide,
  .measurement-guide,
  .faq-section {
    padding: 26px 20px;
    margin: 24px 12px 44px;
  }

  .suit-sizing-guide h2,
  .measurement-guide h2,
  .faq-section h2,
  .other-calculators h2 {
    font-size: 1.9em;
  }

  .suit-sizing-guide h3,
  .measurement-guide h3,
  .faq-section h3 {
    font-size: 1.35em;
  }

  .suit-sizing-guide p,
  .measurement-guide p,
  .faq-section p,
  .suit-sizing-guide li {
    font-size: 1rem;
  }
}

/* =========================================================
   Small Mobile Adjustments
   ========================================================= */

@media (max-width: 600px) {
  header {
    padding: 0 14px;
  }

  main {
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 18px;
    padding-bottom: 10px;
  }

  .hero h1 {
    font-size: 2.35rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .calculator {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 22px 12px;
  }

  .section-title {
    font-size: 2rem;
  }

  .height-wrapper {
    gap: 14px;
  }

  label {
    font-size: 1rem;
  }

  input[type="number"] {
    font-size: 1rem;
    padding: 13px;
  }

  .clear-btn,
  .calc-btn {
    padding: 14px;
    font-size: 1rem;
  }

  .main-size {
    font-size: 2.5em;
  }

  .info:hover::after {
    width: 180px;
  }

  .other-calculators {
    gap: 12px;
    padding: 0 10px;
    margin: 44px auto;
  }

  .other-calculators .calc-card {
    flex: 0 1 100%;
    max-width: 320px;
    min-height: 230px;
    padding-top: 28px;
  }

  th,
  td {
    padding: 12px;
    font-size: 0.95rem;
  }
}

/* =========================================================
   Final Logo Display Override
   Keeps only one logo visible at each screen size
   ========================================================= */

.logo-desktop {
  display: block !important;
}

.logo-mobile {
  display: none !important;
}

@media (max-width: 768px) {
  .logo-desktop {
    display: none !important;
  }

  .logo-mobile {
    display: block !important;
  }
}