@import url('/calculator-base.css');

:root {
  --teal: #00a69b;
  --teal-dark: #008e84;
  --navy: #0b3150;
  --line: #d4e2e6;
  --soft: #f5faf9;
}

/* Page introduction */
.page-intro {
  width: min(75%, 1050px);
  max-width: none;
  margin: 0 auto;
  padding: clamp(1.35rem, 3vw, 2.45rem) 0 3.15rem;
  background: transparent;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: 0 0 1.25rem;
  color: #617b89;
  font-size: .8rem;
  font-weight: 500;
}

.breadcrumb-home {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  color: var(--teal-dark);
  text-decoration: none;
}

.breadcrumb-home:hover { color: var(--navy); }
.breadcrumb-home svg { width: .9rem; height: .9rem; }
.breadcrumb strong { color: var(--navy); font-weight: 600; }

.page-intro .eyebrow { margin-bottom: .5rem; }
.page-intro h1 { max-width: none; margin-bottom: .65rem; }
.page-intro > p:not(.eyebrow) { max-width: none; margin-bottom: 0; }

/* Calculator workspace */
.calculator-shell,
.results-section {
  width: min(75%, 1050px);
  max-width: none;
  margin-left: auto;
  margin-right: auto;
}

.calculator-shell { margin-top: -1.05rem; padding: 0; }

.calculator-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.35rem 1.5rem;
  color: #fff;
  background: var(--navy);
  border: 1px solid var(--navy);
  border-radius: 13px 13px 0 0;
}

.calculator-head .eyebrow { color: #79dfd7; margin-bottom: .35rem; }
.calculator-head h2 { margin: 0; color: #fff; font-size: clamp(1.4rem, 2.5vw, 1.8rem); }
.calculator-head > p { max-width: 390px; margin: 0; color: #d4ebec; font-size: .79rem; line-height: 1.58; }

.mode-tabs {
  display: grid;
  width: 100%;
  max-width: 100%;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .55rem;
  padding: .8rem 1.25rem;
  border: 1px solid var(--line);
  border-top: 0;
  background: #fff;
}

.mode-tab {
  min-width: 0;
  max-width: 100%;
  min-height: 4.35rem;
  padding: .7rem .65rem;
  color: #416774;
  background: #f7fbfb;
  border: 1px solid #dbe8eb;
  border-radius: 8px;
  font-family: inherit;
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.mode-tab small { display: block; margin-top: .18rem; color: #718893; font-size: .63rem; font-weight: 400; }
.mode-tab:hover { border-color: #8bcfc9; color: var(--teal-dark); }
.mode-tab.active { color: var(--navy); background: #e9f8f6; border-color: var(--teal); }
.mode-tab.active small { color: #365f70; }
.mode-tabs .mode-tab:last-child { border-right: 1px solid #dbe8eb; }
.mode-tabs .mode-tab.active:last-child { border-right-color: var(--teal); }
.mode-tab:focus-visible,
.calculator-form :is(input, select, button):focus-visible,
.copy-button:focus-visible,
.page-toc a:focus-visible { outline: 3px solid rgba(0, 166, 155, .28); outline-offset: 2px; }

.calculator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 13px 13px;
  background: #fff;
}

.calculator-form { padding: 1.45rem 1.5rem 1.55rem; }

.basis-box {
  margin: 0 0 1.25rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--soft);
}

.basis-box .field-grid,
.mode-panel .field-grid { align-items: start; }

.calculator-form fieldset { margin: 0; padding: 0; border: 0; }
.calculator-form legend {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: 0 0 1rem;
  color: var(--navy);
  font-size: 1rem;
  font-weight: 700;
}

.calculator-form legend span {
  display: inline-grid;
  width: 1.65rem;
  height: 1.65rem;
  flex: 0 0 1.65rem;
  place-items: center;
  margin: 0;
  color: #fff;
  background: var(--teal);
  border-radius: 50%;
  font-size: .72rem;
  line-height: 1;
}

.calculator-form .field label { color: var(--navy); font-weight: 600; }
.calculator-form :is(input, select) {
  min-height: 2.75rem;
  color: var(--navy);
  border-color: #bdd2d8;
  border-radius: 7px;
  box-shadow: none;
}

.calculator-form select {
  padding-right: 3.2rem;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%230b3150' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1.1rem center;
  background-size: .8rem;
}

.calculator-form :is(input, select):focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 166, 155, .14);
  outline: 0;
}

.calculator-form .compound {
  min-height: 2.75rem;
  overflow: hidden;
  border: 1px solid #bdd2d8;
  border-radius: 7px;
  background: #fff;
}

.calculator-form .compound :is(input, select) {
  min-height: 2.65rem;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.calculator-form .compound .unit-display {
  display: flex;
  align-items: center;
  min-height: 2.65rem;
  background: #eef5f5;
  border: 0;
  border-left: 1px solid #bdd2d8;
  border-radius: 0;
}

.calculator-form .compound:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 166, 155, .14);
}

.calculator-form .compound :is(input, select):focus { box-shadow: none; }
.calculator-form .helper { margin-top: .38rem; color: #617c88; }
.calculator-form .check-row { align-items: flex-start; }
.calculator-form .check-row input { min-height: auto; margin-top: .28rem; accent-color: var(--teal); }
.calculator-form .check-row label { color: #416774; font-weight: 400; }

.form-actions { display: flex; align-items: center; gap: .95rem; margin-top: 1.45rem; }
.primary-button { background: var(--teal); border-color: var(--teal); box-shadow: none; }
.primary-button:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.text-button { color: var(--teal-dark); }
.input-error { min-height: 0; margin: .8rem 0 0; }

.start-panel {
  display: block;
  padding: 1.4rem 1.25rem;
  color: #385e6c;
  background: var(--soft);
  border-left: 1px solid var(--line);
}

.start-panel h3 { margin: 0 0 .55rem; color: var(--navy); font-size: .95rem; }
.start-panel > p { margin: 0; font-size: .73rem; line-height: 1.6; }
.start-points { display: grid; gap: .5rem; margin-top: 1rem; }
.start-points span { padding: .53rem .55rem; color: #356571; background: #e7f3f2; border-radius: 6px; font-size: .66rem; font-weight: 600; line-height: 1.35; }

/* Results */
.results-section { margin-top: 3.25rem; padding: 0; }
.results-card { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: none; }
.result-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.35rem 1.5rem 1rem; }
.result-header .eyebrow { margin-bottom: .3rem; }
.result-header h2 { margin: 0; color: var(--navy); font-size: clamp(1.3rem, 2vw, 1.65rem); }
.result-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
.copy-button { display: inline-flex; align-items: center; justify-content: center; gap: .43rem; min-height: 2.4rem; padding: .5rem .75rem; color: var(--teal-dark); background: #fff; border: 1px solid #bcd9d7; border-radius: 7px; font: 600 .72rem/1 Poppins, sans-serif; cursor: pointer; }
.copy-button:hover { color: #fff; background: var(--teal); border-color: var(--teal); }
.copy-button svg { width: .95rem; height: .95rem; flex: 0 0 .95rem; }

.primary-result { padding: 1.45rem 1.5rem; color: #fff; background: var(--navy); }
.result-label { color: #7ce4dc; }
.primary-result > p { margin: .38rem 0; color: #fff; }
.result-summary { max-width: 690px; color: #d4ebec; }
.field-checkpoint { margin: .9rem 0 0; color: #fff; font-size: .86rem; font-weight: 600; line-height: 1.5; }
.result-status { display: inline-flex; margin-top: .7rem; padding: .3rem .6rem; border-radius: 99px; color: #075f4d; background: #dff6ed; font-size: .68rem; font-weight: 700; }
.result-status[hidden] { display: none; }
.result-status.fail { color: #a13b34; background: #ffe8e5; }

.metric-grid { gap: .75rem; padding: 1.2rem 1.5rem; background: #fff; }
.metric-grid article { min-height: 6.5rem; padding: .85rem; border: 1px solid #dbe8eb; border-radius: 8px; background: #fbfdfd; box-shadow: none; }
.metric-grid span { color: #54717e; }
.metric-grid strong { color: var(--navy); }
.field-setout { margin: 1.25rem 1.5rem 0; padding: 1rem; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.field-setout-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: .85rem; }
.field-setout-heading .eyebrow { margin-bottom: .2rem; }
.field-setout h3 { margin: 0; color: var(--navy); font-size: 1rem; }
.field-setout-heading > p { max-width: 20rem; margin: 0; color: #617c88; font-size: .74rem; line-height: 1.45; text-align: right; }
.field-setout-table-wrap { margin: 0; overflow-x: auto; border: 1px solid #dbe8eb; border-radius: 7px; }
.field-setout-table-wrap table { width: 100%; min-width: 0; margin: 0; border-collapse: collapse; }
.field-setout-table-wrap :is(th, td) { padding: .65rem .75rem; text-align: left; }
.field-setout-table-wrap th { color: #446775; background: #f3f9f9; font-size: .68rem; letter-spacing: .03em; text-transform: uppercase; }
.field-setout-table-wrap td { color: var(--navy); border-top: 1px solid #e2ecee; font-size: .79rem; font-weight: 500; }
.result-note { margin: 1.25rem 1.5rem 1rem; border-left-color: var(--teal); background: #eff9f8; }
.result-note strong { color: var(--navy); }
.math-details { margin: 0 1.5rem 1.4rem; border-color: var(--line); border-radius: 8px; }
.math-details summary { display: flex; align-items: center; justify-content: space-between; min-height: 2.8rem; padding: 0 .9rem; color: var(--navy); font-weight: 500; cursor: pointer; list-style: none; }
.math-details summary::-webkit-details-marker { display: none; }
.math-details summary::after { content: '+'; color: var(--teal-dark); font-size: 1.1rem; font-weight: 700; }
.math-details[open] summary::after { content: '−'; }
.math-details > div { padding: 0 .9rem .9rem; }

/* Supporting content and table of contents */
.page-body-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 245px;
  grid-template-areas: 'content sidebar';
  gap: 3.5rem;
  align-items: start;
  width: min(75%, 1050px);
  margin: 3.4rem auto 0;
  padding-bottom: 3rem;
}

.page-content { display: flex; flex-direction: column; grid-area: content; min-width: 0; }
.page-content > * { width: auto; max-width: none; margin: 0; padding: 0; }
.page-content > * + * { margin-top: 2.65rem; }
.page-sidebar { position: sticky; top: 1.5rem; grid-area: sidebar; }

.page-sidebar .page-toc {
  display: block;
  width: auto;
  margin: 0;
  padding: 1.15rem;
  color: #fff;
  background: var(--teal);
  border: 1px solid var(--teal);
  border-radius: 12px;
}

.toc-intro { padding: .05rem 0 0; }
.page-sidebar .page-toc-label { margin: 0 0 .28rem; color: #fff; font-size: .88rem; font-weight: 700; letter-spacing: -.02em; }
.page-sidebar .toc-intro > p:last-child { margin: 0 0 .9rem; color: #fff; font-size: .68rem; line-height: 1.5; }
.page-sidebar .page-toc ol { display: grid; grid-template-columns: 1fr; gap: .5rem; margin: 0; padding: 0; list-style: none; counter-reset: toc; }
.page-sidebar .page-toc li { min-width: 0; padding: 0; counter-increment: toc; }
.page-sidebar .page-toc li::before { display: none; }
.page-sidebar .page-toc a { display: flex; align-items: center; gap: .6rem; min-height: 2.7rem; padding: .55rem .7rem; color: #fff; background: rgba(255, 255, 255, .1); border: 0; border-radius: 8px; font-size: .72rem; font-weight: 400; line-height: 1.35; text-decoration: none; }
.page-sidebar .page-toc a::before { content: counter(toc, decimal-leading-zero); display: inline-grid; width: 1.75rem; height: 1.75rem; flex: 0 0 1.75rem; place-items: center; color: var(--teal-dark); background: #fff; border-radius: 50%; font-size: .59rem; font-weight: 700; letter-spacing: .04em; }
.page-sidebar .page-toc a:hover { background: rgba(255, 255, 255, .2); }

.page-content .drain-diagrams { width: auto; max-width: none; margin: 0; padding: 0; }
.drain-diagrams { display: grid; gap: 3.25rem; }
.drain-diagram { display: grid; gap: 1.05rem; }
.drain-diagram-heading .eyebrow { margin-bottom: .55rem; }
.drain-diagram-heading h2 { margin: 0; color: var(--navy); font-size: clamp(1.5rem, 2.5vw, 2rem); line-height: 1.16; letter-spacing: -.035em; }
.drain-illustration { display: grid; gap: .7rem; width: min(100%, 620px); margin: .15rem auto 0; }
.drain-illustration img { display: block; width: 100%; height: auto; border: 1px solid #e1ecee; border-radius: 10px; object-fit: contain; }
.drain-illustration figcaption { color: #617c88; font-size: .86rem; line-height: 1.55; }
.drain-diagram-copy { display: grid; gap: .9rem; }
.drain-diagram-copy p { max-width: none; margin: 0; color: #426474; font-size: 1.03rem; line-height: 1.72; }

.content-section .eyebrow {
  margin-bottom: .45rem;
  color: var(--teal);
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .13em;
  line-height: 1.35;
  text-transform: uppercase;
}
.content-section h2 { margin-top: 0; margin-bottom: .8rem; color: var(--navy); }
.content-section :is(p, li) { font-size: 1rem; line-height: 1.72; }
.steps { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.steps li { min-height: 0; padding: 1rem; background: #fff; border: 1px solid #dbe8eb; border-radius: 9px; box-shadow: none; }
.steps li::before {
  display: inline-grid;
  width: 1.65rem;
  height: 1.65rem;
  place-items: center;
  margin-bottom: .55rem;
  color: var(--teal-dark);
  background: #e8f8f6;
  border-radius: 50%;
  line-height: 1;
}
.steps h3 { color: var(--navy); }
.copy-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.copy-grid article { min-height: 0; padding: 1rem; border: 1px solid #dbe8eb; border-radius: 9px; background: #fff; box-shadow: none; }
.copy-grid h3 { color: var(--navy); }
.example-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.example-grid article { display: flex; flex-direction: column; gap: .75rem; }
.example-grid h3 { margin: .1rem 0 0; font-size: .98rem; }
.example-grid p { margin: 0; }
.example-grid .example-check { margin-top: auto; padding-top: .75rem; color: #426474; border-top: 1px solid #e4eeee; font-size: .82rem; line-height: 1.5; }
.example-grid .example-check strong { color: var(--navy); }
.example-illustration { display: grid; gap: .5rem; margin: 0 0 .2rem; }
.example-illustration img { display: block; width: 100%; height: auto; aspect-ratio: 2 / 1; object-fit: cover; border: 1px solid #e1ecee; border-radius: 7px; }
.example-illustration figcaption { color: #617c88; font-size: .78rem; line-height: 1.45; }
.table-wrap { border-color: var(--line); border-radius: 9px; }
.table-wrap th { color: var(--navy); background: #edf7f6; }
.table-wrap td { color: #365f70; }
#requirements .table-wrap th { padding: .9rem 1rem; font-size: .74rem; }
#requirements .table-wrap td { padding: 1rem; font-size: .92rem; line-height: 1.55; }
.code-clarification { margin: .9rem 0 0; padding: .8rem 1rem; color: #365f70; background: #eff9f8; border-left: 3px solid var(--teal); border-radius: 0 7px 7px 0; }
.code-clarification strong { color: var(--navy); }
#formulas .table-wrap th { padding: .9rem 1rem; font-size: .74rem; }
#formulas .table-wrap td { padding: 1rem; font-size: .92rem; line-height: 1.55; }
.technical-details { margin-top: 1rem; border: 1px solid var(--line); border-radius: 8px; }
.technical-details summary { display: flex; align-items: center; justify-content: space-between; min-height: 2.9rem; padding: 0 .9rem; color: var(--navy); font-weight: 500; cursor: pointer; list-style: none; }
.technical-details summary::-webkit-details-marker { display: none; }
.technical-details summary::after { content: '+'; color: var(--teal-dark); font-size: 1.1rem; font-weight: 700; }
.technical-details[open] summary::after { content: '−'; }
.technical-details p { margin: 0; padding: 0 .9rem .95rem; }
.source-list { margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.source-list li { margin: 0; padding: .9rem 1rem; border-bottom: 1px solid var(--line); }
.source-list li:last-child { border-bottom: 0; }
.source-list li::before { display: none; }
.source-list a { color: var(--teal-dark); font-weight: 600; }
#faq-title .faq-grid { display: grid; grid-template-columns: 1fr; gap: .75rem; }
#faq-title .faq-grid details { padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: none; }
#faq-title .faq-grid summary { color: var(--navy); font-size: .9rem; font-weight: 600; cursor: pointer; }
#faq-title .faq-grid p { margin: .7rem 0 0; color: #526f7e; font-size: 1rem; line-height: 1.72; }

/* Print report */
.print-report { display: none; }

@media (max-width: 960px) {
  .page-body-layout { gap: 2.25rem; }
}

@media (max-width: 767px) {
  .page-intro,
  .calculator-shell,
  .results-section { width: auto; margin-left: clamp(1.25rem, 8vw, 10rem); margin-right: clamp(1.25rem, 8vw, 10rem); }

  .page-intro { padding-top: 1.15rem; padding-bottom: 2.25rem; }
  .breadcrumb { margin-bottom: 1rem; }
  .calculator-shell { margin-top: 0; }
  .calculator-head { display: block; padding: 1.15rem; }
  .calculator-head > p { margin-top: .8rem; }
  .mode-tabs { grid-template-columns: 1fr; }
  .mode-tab { min-height: 0; }
  .calculator-layout { grid-template-columns: 1fr; border-radius: 0 0 12px 12px; }
  .calculator-form { padding: 1.15rem; }
  .calculator-form .field-grid { grid-template-columns: 1fr; }
  .start-panel { display: block; border-top: 1px solid var(--line); border-left: 0; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .primary-button,
  .text-button { width: 100%; }

  .results-section { margin-top: 2.4rem; }
  .result-header { align-items: flex-start; padding: 1.15rem 1.15rem .9rem; }
  .result-actions { justify-content: flex-start; }
  .copy-button { min-width: 2.5rem; padding: .6rem; }
  .copy-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .primary-result { padding: 1.2rem 1.15rem; }
  .field-checkpoint { font-size: .82rem; }
  .metric-grid { grid-template-columns: 1fr; padding: 1rem 1.15rem; }
  .metric-grid article { min-height: 0; }
  .result-note,
  .math-details,
  .field-setout { margin-left: 1.15rem; margin-right: 1.15rem; }
  .field-setout { padding: .9rem; }
  .field-setout-heading { display: block; }
  .field-setout-heading > p { margin-top: .35rem; text-align: left; }

  .page-body-layout { grid-template-columns: 1fr; grid-template-areas: 'sidebar' 'content'; gap: 2.4rem; width: auto; margin: 2.4rem clamp(1.25rem, 8vw, 10rem) 0; padding-bottom: 2.4rem; }
  .page-sidebar { position: static; }
  .page-content > * + * { margin-top: 2.25rem; }
  .copy-grid,
  .steps,
  .example-grid { grid-template-columns: 1fr; }
  .drain-diagrams { gap: 2.4rem; }
  .drain-diagram { gap: .9rem; }
  .drain-illustration { width: min(100%, 540px); }
  .drain-diagram-copy p,
  .content-section :is(p, li),
  .faq-grid p { font-size: .96rem; }
  .table-wrap { overflow-x: auto; }
}

@media print {
  @page { margin: 16mm; }

  body { background: #fff; color: #000; font-size: 10pt; }
  .site-header,
  .page-intro,
  .calculator-shell,
  .page-body-layout,
  .site-footer { display: none !important; }

  main,
  .results-section,
  .results-card { display: block !important; width: 100% !important; margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; }
  .results-section[hidden] { display: none !important; }
  .print-report { display: block; margin-bottom: 1.25rem; }
  .print-report-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: .45rem; border-bottom: 1px solid #80949a; color: #17384c; }
  .print-report-header p { margin: 0; font-weight: 700; }
  .print-report-title { margin: .7rem 0 1rem; color: #0b3150; font-size: 22pt; font-weight: 700; }
  .print-input-summary { padding: .85rem 1rem; border: 1px solid #b9cbd0; border-radius: 7px; }
  .print-input-summary h2 { margin: 0 0 .45rem; color: #0b3150; font-size: 12pt; }
  .print-input-summary dl { display: grid; grid-template-columns: 1fr 1fr; gap: .38rem 1rem; margin: 0; }
  .print-input-summary div { display: grid; grid-template-columns: 45% 1fr; gap: .35rem; }
  .print-input-summary dt { color: #526a74; font-weight: 600; }
  .print-input-summary dd { margin: 0; }
  .result-header { padding: 0 0 .7rem; }
  .result-header .eyebrow,
  .copy-button,
  .math-details { display: none !important; }
  .result-header h2 { font-size: 16pt; }
  .primary-result { padding: .9rem 1rem; color: #000; background: #eef6f5 !important; border: 1px solid #b9d8d3; }
  .primary-result :is(p, .result-label, .result-summary) { color: #000 !important; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); padding: .85rem 0; }
  .metric-grid article { min-height: 0; break-inside: avoid; }
  .result-note { margin: 0; }
}
