/* Animal Dose Converter - UI styles.
   Plain CSS, no framework. Same palette as LabCalculators/css/style.css so
   the two tools read as one piece of software. Contrast: body text #1F2937
   and muted #45525e on white are 14.7:1 and 8.5:1; the #15803D accent is
   5.0:1 under white text (WCAG AA 4.5:1). */

:root {
  --bg: #F0FDF4;
  --card: #FFFFFF;
  --ink: #1F2937;
  --ink-soft: #45525e;
  --head: #14532D;
  --line: #BBF7D0;
  --field-line: #7C8794; /* 3.6:1 on white, so input boxes read as boxes */
  --accent: #15803D;
  --error: #8a1c1c;
  --warn-bg: #FFFBEB;
  --warn-line: #FDE68A;
  --warn-ink: #78350F;
  --focus: #0b5cd5;
  --radius: 10px;
  --chrome: 6.4rem; /* body padding + nav + gap above the tool window */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0.75rem clamp(0.75rem, 3vw, 1.5rem) 0;
  font: 15px/1.5 "Public Sans", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  line-height: 1;
}

/* ------------------------------------------------------------- site nav -- */

.site-nav {
  max-width: 1400px;
  margin: 0 auto 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 10px clamp(14px,4vw,24px);
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(20,83,45,0.08);
}

.site-nav .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }

.site-nav .brand img {
  width: clamp(32px,8vw,38px);
  height: clamp(28px,7vw,34px);
  object-fit: contain;
  border-radius: 10px;
  background: var(--bg);
}

.site-nav .brand span { font-weight: 700; font-size: clamp(17px,4.5vw,21px); color: var(--head); letter-spacing: 0.2px; }

.nav-toggle { display: none; }

.nav-burger {
  display: none;
  cursor: pointer;
  font-size: clamp(20px,6vw,28px);
  line-height: 1;
  color: var(--head);
  user-select: none;
}

.site-nav ul { list-style: none; display: flex; gap: 28px; margin: 0; padding: 0; flex-wrap: wrap; }
.site-nav ul a { text-decoration: none; color: #374151; font-size: 15px; }
.site-nav ul a:hover { color: var(--head); }
.site-nav ul a.active { color: var(--head); font-weight: 600; border-bottom: 2px solid #4ADE80; padding-bottom: 4px; }

@media (max-width: 768px) {
  .nav-burger { display: block !important; order: 2; }
  .site-nav .brand { order: 1; }
  .site-nav ul { display: none !important; flex-basis: 100%; order: 3; flex-direction: column; gap: 16px; background: var(--card); border-radius: 14px; padding: 12px; margin-top: 8px; }
  .nav-toggle:checked ~ ul { display: flex !important; }
}

/* ---------------------------------------------------------- tool window -- */

/* Inputs left, answer right, both inside one screen: no scrolling between
   typing a dose and reading the result. */
.app {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 30rem) minmax(0, 1fr);
  gap: 0.9rem;
  height: calc(100vh - var(--chrome));
  height: calc(100dvh - var(--chrome));
  min-height: 34rem;
  padding-bottom: 0.75rem;
}

.pane {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.2rem;
  box-shadow: 0 1px 3px rgba(20,83,45,0.06);
}

.pane-out { display: flex; flex-direction: column; gap: 0.75rem; }

.app-head { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.7rem; }

.app-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 12px;
  background: var(--line);
  color: var(--head);
  font-size: 1.35rem;
}

h1 { margin: 0; font-size: 1.3rem; line-height: 1.2; color: var(--head); }
.tagline { margin: 0.1rem 0 0; font-size: 0.85rem; color: var(--ink-soft); }

.pane-title { margin: 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }

h3 { font-size: 0.85rem; margin: 0.8rem 0 0.3rem; color: var(--head); }

/* ------------------------------------------------------ segmented radios -- */

fieldset.seg { border: 0; margin: 0 0 0.7rem; padding: 0; min-width: 0; }
.seg legend { padding: 0; margin-bottom: 0.3rem; font-weight: 600; font-size: 0.85rem; }

.seg-row {
  display: flex;
  border: 1px solid var(--field-line);
  border-radius: var(--radius);
  overflow: hidden;
}

.seg label { position: relative; flex: 1 1 0; min-width: 0; }
.seg label + label { border-left: 1px solid var(--field-line); }

/* The real radio covers its whole segment (transparent, on top), so a click
   anywhere on the segment is a click on the radio itself. */
.seg input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.seg span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0.45rem 0.5rem;
  text-align: center;
  font-size: 0.87rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
  background: var(--card);
}

.seg input:hover + span { background: var(--bg); }
.seg input:checked + span { background: var(--accent); color: #FFFFFF; }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -3px; }

/* ----------------------------------------------------------------- fields -- */

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.55rem 0.8rem;
  margin-bottom: 0.7rem;
}

.field { display: flex; flex-direction: column; min-width: 0; }
.field[hidden], .hint[hidden] { display: none; }
.field label { font-weight: 600; margin-bottom: 0.2rem; font-size: 0.87rem; }

input, select, button { font: inherit; }

.field select,
.field input,
.helper-row input,
.helper-row select,
.extra-row input {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--field-line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  min-width: 0;
}

.field select, .field input { width: 100%; }
input[type="number"] { font-variant-numeric: tabular-nums; }

.hint { margin: 0.2rem 0 0; font-size: 0.78rem; line-height: 1.35; color: var(--ink-soft); }

/* Fields sit in named slots so the weights always pair up side by side,
   whichever fields the current method and direction show. */
.f-sp { grid-area: sp; }
.f-st { grid-area: st; }
.f-dose { grid-area: dose; }
.f-ex { grid-area: ex; }
.f-wf { grid-area: wf; }
.f-wt { grid-area: wt; }
.f-wh { grid-area: wh; margin-top: -0.2rem; }
.field-grid { grid-template-areas: "sp dose" "wf wt" "wh wh" "ex ."; }
.field-grid[data-layout="pair"] { grid-template-areas: "sp st" "dose ex" "wf wt" "wh wh"; }

.actions { display: flex; gap: 0.6rem; margin-bottom: 0.8rem; }

button {
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
}

button[type="submit"] { flex: 1 1 auto; background: var(--accent); color: #FFFFFF; font-weight: 700; }
button[type="submit"]:hover { filter: brightness(0.93); }

#reset-btn, #copy-btn {
  background: var(--card);
  color: var(--ink);
  border-color: var(--field-line);
}

#reset-btn:hover, #copy-btn:hover { border-color: var(--accent); color: var(--head); }

/* Visible focus ring for every interactive element (WCAG 2.4.7). */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------------------------------------------------------- disclosures -- */

details.panel-more {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem 0.8rem;
  font-size: 0.87rem;
}

details.panel-more + details.panel-more { margin-top: 0.5rem; }
details.panel-more summary { cursor: pointer; font-weight: 600; color: var(--head); }
details.panel-more[open] summary { margin-bottom: 0.4rem; }
details.panel-more ul { padding-left: 1.1rem; margin: 0.3rem 0; }
details.panel-more li { margin-bottom: 0.4rem; }
details.panel-more p { margin: 0.3rem 0; }

.helper-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0.4rem 0; }
.helper-row label { font-weight: 600; min-width: 2.8rem; }
.helper-row input { flex: 1 1 6rem; }
.helper-row select { flex: 0 1 auto; }
.helper-row output { flex: 1 0 100%; font-weight: 600; color: var(--head); font-variant-numeric: tabular-nums; min-height: 1.3em; }

/* ---------------------------------------------------------------- result -- */

.empty-state {
  margin: 0;
  padding: 1.4rem;
  border: 1px dashed var(--field-line);
  border-radius: var(--radius);
  color: var(--ink-soft);
  text-align: center;
}

.empty-state[hidden] { display: none; }

.error-text {
  margin: 0;
  color: var(--error);
  font-weight: 600;
  border: 1px solid var(--error);
  border-radius: var(--radius);
  padding: 0.75rem;
  background: #FEF2F2;
}

.result-card { display: flex; flex-direction: column; gap: 0.6rem; }
.result-card[hidden] { display: none; }

.result-value {
  margin: 0;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--head);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.fda-factor { margin: 0; font-size: 0.83rem; color: var(--ink-soft); }
.fda-factor[hidden] { display: none; }

.warn-list {
  margin: 0;
  padding: 0.55rem 0.8rem 0.55rem 1.8rem;
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 0.86rem;
  font-weight: 600;
}

.warn-list[hidden] { display: none; }
.warn-list li + li { margin-top: 0.3rem; }

.extras { display: flex; flex-direction: column; gap: 0.45rem; }

.extra-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.5rem;
  font-size: 0.9rem;
}

.extra-row[hidden] { display: none; }
.extra-row label { font-weight: 600; }
.extra-row input { width: 6.5rem; }
.extra-row output { font-weight: 700; color: var(--head); font-variant-numeric: tabular-nums; }
.span-all { flex: 1 0 100%; margin-top: 0; }

.result-actions { display: flex; gap: 0.5rem; }

.mono {
  margin: 0;
  font-family: ui-monospace, Consolas, Menlo, monospace;
  font-size: 0.85rem;
  background: var(--bg);
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.intermediate-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.25rem 1rem; margin: 0; }
.intermediate-list dt { font-weight: 600; color: var(--ink-soft); }
.intermediate-list dd { margin: 0; font-family: ui-monospace, Consolas, Menlo, monospace; overflow-wrap: anywhere; }

#reference-text { margin: 0; font-size: 0.85rem; }

.pane-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.5rem; }

.disclaimer {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin: 0;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 0.82rem;
}

.disclaimer .material-symbols-outlined { font-size: 1.1rem; }

/* ---------------------------------------------------------------- footer -- */

.site-footer {
  margin: 0 calc(-1 * clamp(0.75rem, 3vw, 1.5rem));
  padding: clamp(24px,6vw,40px) clamp(16px,5vw,48px) clamp(16px,4vw,28px);
  background-color: #14532D;
  background-image: linear-gradient(160deg,#14532D 0%,#166534 100%);
  color: #DCFCE7;
  font-size: 0.8rem;
}

.footer-top { max-width: 1080px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: clamp(12px,3vw,24px); }
.footer-brand { display: flex; align-items: center; gap: 12px; }
.footer-brand img { width: 32px; height: 32px; object-fit: contain; border-radius: 8px; background: var(--bg); }
.footer-brand span { font-weight: 600; font-size: 17px; color: #FFFFFF; }
.site-footer ul { list-style: none; display: flex; flex-wrap: wrap; gap: clamp(12px,3vw,24px); margin: 0; padding: 0; }
.site-footer a { color: #DCFCE7; text-decoration: none; font-size: 14px; }
.site-footer a:hover { color: #FFFFFF; }
.site-footer .copyright { max-width: 1080px; margin: clamp(12px,3vw,24px) auto 0; padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.15); text-align: center; color: #86EFAC; }

/* ---------------------------------------------------------------- narrow -- */

/* Short laptop screens: tighten so the form still fits without scrolling. */
@media (min-width: 901px) and (max-height: 760px) {
  .tagline, .pane-title { display: none; }
  .pane-out { gap: 0.55rem; }
  details.panel-more { padding: 0.4rem 0.75rem; }
  .app-head { margin-bottom: 0.45rem; }
  .pane { padding: 0.8rem 1rem; }
  fieldset.seg { margin-bottom: 0.5rem; }
  .seg span { padding-top: 0.35rem; padding-bottom: 0.35rem; }
  .field select, .field input { padding-top: 0.35rem; padding-bottom: 0.35rem; }
  .field-grid { gap: 0.4rem 0.8rem; margin-bottom: 0.5rem; }
  .actions { margin-bottom: 0.55rem; }
}

@media (max-width: 900px) {
  .app { display: flex; flex-direction: column; height: auto; min-height: 0; }
  .pane { overflow: visible; }
  .site-nav { position: sticky; top: 0.5rem; z-index: 100; }
}

@media (max-width: 560px) {
  .field-grid, .field-grid[data-layout="pair"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "sp" "st" "dose" "wf" "wt" "wh" "ex";
  }
  .seg-row { flex-direction: column; }
  .seg label + label { border-left: 0; border-top: 1px solid var(--field-line); }
  .actions { flex-direction: column; }
  .result-value { font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
