/* ---------------------------------------------------------------------------
   Blood results trend visualiser — anne healthcare house-style demo.
   Self-contained stylesheet. Tokens match the bloods tool and hub page.
--------------------------------------------------------------------------- */

:root {
  --cta:            #1a67cc;
  --cta-dark:       #14509f;
  --accent:         #18d6c4;
  --accent-dark:    #13a89a;
  --cream:          #f4eed7;
  --cream-border:   #e9ddaf;
  --cool:           #e5eef8;
  --dark:           #333;
  --grey:           #4d4d4d;
  --grey-soft:      #676767;
  --grey-line:      #e0e0e0;
  --light:          #fff;
  --danger:         #c12727;

  --font-heading:   "Inter", system-ui, sans-serif;
  --font-body:      "DM Sans", system-ui, sans-serif;

  --radius-sm:      0.5rem;
  --radius-md:      1.5rem;
  --radius-pill:    100em;
  --shadow-soft:    0 3px 6px 0 rgba(0, 0, 0, 0.06);
  --shadow-lift:    0 12px 32px -16px rgba(20, 80, 159, 0.22),
                    0  3px  6px  0   rgba(0, 0, 0, 0.06);

  --content-max:    112rem;
  --gutter:         clamp(2rem, 5vw, 6rem);

  /* Chart-specific */
  --ref-fill:       rgba(24, 214, 196, 0.12);
  --ref-stroke:     rgba(24, 214, 196, 0.35);
  --line-color:     #1a67cc;
  --dot-color:      #1a67cc;
  --dot-hover:      #14509f;
  --grid-color:     #eaeaea;
  --in-range-bg:    #e8f5e9;
  --in-range-fg:    #2e7d32;
  --out-range-bg:   #ffebee;
  --out-range-fg:   #c12727;
}

/* 10px rem base */
html { font-size: 62.5%; -webkit-text-size-adjust: 100%; }

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

body {
  margin: 0;
  background: var(--light);
  color: var(--dark);
  font-family: var(--font-body);
  font-size: 1.7rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-image:
    radial-gradient(ellipse 90rem 50rem at 8% -10%,  rgba(229, 238, 248, 0.9), transparent 60%),
    radial-gradient(ellipse 70rem 40rem at 100% 5%,  rgba(244, 238, 215, 0.65), transparent 55%);
  background-repeat: no-repeat;
}

a { color: var(--cta); text-decoration: none; }
a:hover { color: var(--cta-dark); text-decoration: underline; }


/* --- Header --------------------------------------------------------------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 2.4rem var(--gutter);
  max-width: var(--content-max);
  margin: 0 auto;
}
.brand { display: inline-flex; }
.brand img { height: 3.6rem; width: auto; display: block; }

.brand-group { display: flex; flex-direction: column; gap: 0.6rem; }
.back-links { display: flex; gap: 1.2rem; }


.back-link {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--grey-soft);
  text-decoration: none;
}
.back-link:hover { color: var(--cta); text-decoration: none; }

.chip {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-pill);
  background: var(--cream);
  color: var(--cta-dark);
  border: 1px solid var(--cream-border);
  white-space: nowrap;
}


/* --- Main layout ---------------------------------------------------------- */

main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 4rem var(--gutter) 8rem;
  display: flex;
  flex-direction: column;
  gap: 3.2rem;
}


/* --- Member banner -------------------------------------------------------- */

.member-banner { max-width: 64rem; }

.kicker {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cta);
  margin: 0 0 1.4rem;
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
}
.kicker::before {
  content: "";
  width: 2.4rem;
  height: 0.2rem;
  background: var(--accent);
  border-radius: 2px;
  display: inline-block;
}
h1 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: clamp(3.8rem, 5.6vw, 6.4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 1.2rem;
  color: var(--dark);
}
.lede {
  font-size: clamp(1.8rem, 1.6vw, 2.1rem);
  line-height: 1.5;
  color: var(--grey);
  margin: 0;
  max-width: 56rem;
}


/* --- Biomarker nav (pills) ------------------------------------------------ */

.marker-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.marker-pill {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--grey);
  background: var(--light);
  border: 1.5px solid var(--grey-line);
  border-radius: var(--radius-pill);
  padding: 0.8rem 1.8rem;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.marker-pill:hover {
  border-color: var(--cta);
  color: var(--cta-dark);
}
.marker-pill:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 103, 204, 0.18);
  border-color: var(--cta);
}
.marker-pill[aria-selected="true"] {
  background: var(--cta);
  border-color: var(--cta);
  color: var(--light);
  box-shadow: 0 6px 14px -6px rgba(26, 103, 204, 0.4);
}
.marker-pill[aria-selected="true"]:hover {
  background: var(--cta-dark);
  border-color: var(--cta-dark);
  color: var(--light);
}

/* Group labels within the pill bar */
.marker-group {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.marker-group__label {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey-soft);
  padding: 0 0.4rem;
  white-space: nowrap;
}
.marker-group__sep {
  width: 1px;
  height: 2rem;
  background: var(--grey-line);
  margin: 0 0.4rem;
  flex-shrink: 0;
}


/* --- Chart section -------------------------------------------------------- */

.chart-section {
  padding: 3rem 3rem 2.4rem;
  position: relative;
}

.chart-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.6rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.chart-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 2.2rem;
  color: var(--dark);
  margin: 0;
}
.chart-unit {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--grey-soft);
  letter-spacing: 0.04em;
}
.chart-ref-label {
  font-size: 1.3rem;
  color: var(--accent-dark);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}
.chart-ref-label::before {
  content: "";
  width: 1.4rem;
  height: 1rem;
  background: var(--ref-fill);
  border: 1px solid var(--ref-stroke);
  border-radius: 2px;
  display: inline-block;
}

.chart-wrap {
  width: 100%;
  position: relative;
}
.chart-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Tooltip */
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--dark);
  color: var(--light);
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 500;
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
  z-index: 10;
  opacity: 0;
  transform: translateY(0.4rem);
  transition: opacity 0.15s, transform 0.15s;
}
.chart-tooltip--visible {
  opacity: 1;
  transform: none;
}
.chart-tooltip__value {
  font-weight: 700;
  font-size: 1.6rem;
  display: block;
}
.chart-tooltip__date {
  font-weight: 400;
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.7);
}
.chart-tooltip__status {
  font-size: 1.1rem;
  margin-top: 0.2rem;
}
.chart-tooltip__status--in {
  color: #6fd992;
}
.chart-tooltip__status--out {
  color: #ff8a80;
}


/* --- Card base ------------------------------------------------------------ */

.card {
  background: var(--light);
  border: 1px solid var(--grey-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}


/* --- Results table -------------------------------------------------------- */

.table-section {}

.table-wrap {
  background: var(--light);
  border: 1px solid var(--grey-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.5rem;
}
.results-table thead {
  background: #fafafa;
  border-bottom: 1px solid var(--grey-line);
}
.results-table th {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--grey-soft);
  padding: 1.2rem 1.6rem;
  text-align: left;
  white-space: nowrap;
}
.results-table td {
  padding: 1.4rem 1.6rem;
  vertical-align: middle;
  border-bottom: 1px solid #f0f0f0;
}
.results-table tbody tr {
  opacity: 0;
  transform: translateY(0.6rem);
  animation: row-in 0.45s cubic-bezier(.22, 1, .36, 1) forwards;
}
@keyframes row-in { to { opacity: 1; transform: none; } }

.results-table tbody tr:last-child td { border-bottom: none; }

.cell-date {
  font-size: 1.4rem;
  color: var(--grey);
  white-space: nowrap;
}
.cell-value {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.6rem;
  color: var(--dark);
  font-variant-numeric: tabular-nums;
}
.cell-unit {
  font-size: 1.4rem;
  color: var(--grey-soft);
}
.cell-range {
  font-size: 1.35rem;
  color: var(--grey-soft);
}

.badge {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.4rem 1.2rem;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.badge--in {
  background: var(--in-range-bg);
  color: var(--in-range-fg);
}
.badge--out {
  background: var(--out-range-bg);
  color: var(--out-range-fg);
}


/* --- Actions -------------------------------------------------------------- */

.actions {
  display: flex;
  gap: 1.2rem;
}

.btn-primary {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--light);
  background: var(--cta);
  border: none;
  border-radius: var(--radius-pill);
  padding: 1.2rem 3.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  box-shadow: var(--shadow-soft);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn-primary:hover {
  background: var(--cta-dark);
  box-shadow: var(--shadow-lift);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-primary svg {
  flex-shrink: 0;
}


/* --- Toast ---------------------------------------------------------------- */

.toast-area {
  position: fixed;
  bottom: 2.4rem;
  right: 2.4rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  pointer-events: none;
}
.toast {
  font-family: var(--font-body);
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--light);
  background: var(--dark);
  padding: 1.2rem 2rem;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  pointer-events: auto;
  animation: toast-in 0.35s cubic-bezier(.22, 1, .36, 1) forwards;
  max-width: 40rem;
}
.toast--out {
  animation: toast-out 0.25s ease forwards;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(1rem) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateY(0.5rem) scale(0.96); }
}


/* --- Footer --------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--grey-line);
  padding: 3rem var(--gutter) 4rem;
  max-width: var(--content-max);
  margin: 4rem auto 0;
  color: var(--grey-soft);
  font-size: 1.35rem;
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--cta); }
.site-footer a:hover { color: var(--cta-dark); }


/* --- Reduced motion ------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .results-table tbody tr,
  .chart-tooltip {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}


/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 720px) {
  :root { --gutter: 2rem; }
  .site-header { padding: 1.8rem var(--gutter); }
  main { padding: 2.4rem var(--gutter) 6rem; gap: 2.4rem; }

  .chart-section { padding: 2rem 1.6rem 1.6rem; }
  .chart-header { flex-direction: column; gap: 0.6rem; }

  .marker-nav { gap: 0.6rem; }
  .marker-pill { font-size: 1.3rem; padding: 0.7rem 1.4rem; }
  .marker-group__label { display: none; }
  .marker-group__sep { display: none; }

  .results-table th,
  .results-table td { padding: 1rem 1.2rem; }
  .col-range { display: none; }
  .results-table td:nth-child(4) { display: none; }

  .btn-primary { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
  .col-unit { display: none; }
  .results-table td:nth-child(3) { display: none; }
}


/* --- Print --------------------------------------------------------------- */

@media print {
  body { background: none; color: #000; font-size: 11pt; }
  .site-header .chip, .site-footer, .marker-nav, .actions,
  .chart-tooltip, .toast-area { display: none !important; }
  main { max-width: none; padding: 0 1cm; }
  .chart-section, .table-wrap { box-shadow: none; border: 1pt solid #888; }
  .results-table tbody tr {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .brand img { filter: grayscale(1); }
}
