/* ============================================================
   SIMBRYO BIOPSY PORTAL — styles.css
   Merged design system (colors_and_type.css) + app styles.
   Font paths are relative to this file → ../assets/fonts/
   ============================================================ */

/* @import must come before all other rules */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;500;600;700&display=swap');

/* ---- Fonts ---- */
@font-face {
  font-family: 'Grandiflora One';
  src: url('../assets/fonts/GrandifloraOne-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geologica';
  src: url('../assets/fonts/Geologica-Variable.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ============================================================
   COLOR TOKENS
   ============================================================ */
:root {
  --color-metal:     #D2E2E0;
  --color-forest:    #053220;
  --color-sage:      #A7C8B7;
  --color-eggplant:  #3D193D;
  --color-lavender:  #BF97C6;
  --color-sunshine:  #F7C65D;
  --color-emerald:   #058277;
  --color-salt:      #FFFEFA;
  --color-black:     #000000;

  --bg-primary:      var(--color-metal);
  --bg-dark:         var(--color-forest);
  --bg-light:        var(--color-salt);

  --text-primary:    var(--color-forest);
  --text-on-dark:    var(--color-salt);
  --text-muted:      #4a6b5a;
  --text-heading:    var(--color-forest);

  --cta-bg:          var(--color-forest);
  --cta-bg-hover:    #042818;
  --cta-text:        var(--color-salt);
  --link:            var(--color-forest);
  --link-hover:      var(--color-emerald);

  --border-default:  rgba(5, 50, 32, 0.15);
  --border-accent:   var(--color-sage);

  --font-display:    'Grandiflora One', Georgia, serif;
  --font-body:       'Geologica', system-ui, sans-serif;
  --font-product:    'Noto Sans', system-ui, sans-serif;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-md:   1.125rem;
  --text-lg:   1.25rem;
  --text-xl:   1.5rem;

  --weight-regular:  400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  --leading-normal:  1.5;
  --leading-relaxed: 1.65;

  --tracking-wide:   0.05em;

  --space-2:   8px;
  --space-3:   12px;
  --space-4:   16px;
  --space-6:   24px;
  --space-8:   32px;

  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  16px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 3px rgba(5,50,32,0.08), 0 1px 2px rgba(5,50,32,0.04);
  --shadow-md: 0 4px 12px rgba(5,50,32,0.10), 0 2px 4px rgba(5,50,32,0.06);

  --transition-fast:    150ms ease-out;
  --transition-default: 250ms ease-out;
}

/* ============================================================
   BASE RESETS
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
  background: #FAFAF8;
  margin: 0;
  min-height: 100vh;
}

a { color: var(--link); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--link-hover); }

/* ============================================================
   APP SHELL
   ============================================================ */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Header ---- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 40px;
  background: var(--color-salt);
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
}
.app-header .logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--color-forest);
  text-decoration: none;
}
.app-header .logo .mark {
  height: 32px;
  width: auto;
  display: block;
}
.app-header .logo .wordmark {
  font-family: var(--font-product);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--color-forest);
  line-height: 1;
  padding-top: 2px;
}
.app-header .kit-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-product);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-forest);
  background: var(--color-metal);
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
}
.app-header .kit-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--color-emerald);
  flex-shrink: 0;
}

/* ---- Page container ---- */
.page {
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 40px 56px;
  flex: 1;
}

/* ---- Footer ---- */
.app-footer {
  padding: 14px 40px 20px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border-default);
  background: var(--color-salt);
  flex-shrink: 0;
}
.app-footer a { color: var(--color-forest); text-decoration: underline; text-underline-offset: 3px; }

/* ============================================================
   STEP INDICATOR
   ============================================================ */
.step-pills {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-product);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.step-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.step-pill .num {
  width: 22px; height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center; justify-content: center;
  background: transparent;
  border: 1.5px solid var(--border-default);
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-body);
  font-weight: 500;
  flex-shrink: 0;
}
.step-pill.active .num { background: var(--color-forest); color: var(--color-salt); border-color: var(--color-forest); }
.step-pill.active { color: var(--color-forest); }
.step-pill.done .num { background: var(--color-sage); border-color: var(--color-sage); color: var(--color-forest); }
.step-pill.done { color: var(--color-forest); }
.step-pill .bar {
  width: 28px;
  height: 1.5px;
  background: var(--border-default);
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
.h-display {
  font-family: var(--font-display);
  font-size: 38px;
  line-height: 1.05;
  color: var(--color-forest);
  letter-spacing: -0.01em;
  -webkit-text-stroke: 0.4px currentColor;
  margin: 0 0 8px;
}
.h-display.sm { font-size: 30px; }

.subhead {
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 0 24px;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-forest);
  display: flex;
  align-items: center;
  gap: 4px;
}
.field-label .req {
  color: #B43D3D;
  margin-left: 2px;
}
.field-help {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: -2px;
}
.field-error {
  font-size: 12.5px;
  color: #B43D3D;
  margin-top: 2px;
}

.field-input,
.field-select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 400;
  color: var(--color-forest);
  background: var(--color-salt);
  border: 1.5px solid var(--border-default);
  border-radius: 10px;
  padding: 10px 14px;
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.field-input::placeholder { color: #97A89C; }
.field-input:focus,
.field-select-wrap select:focus {
  outline: none;
  border-color: var(--color-forest);
  box-shadow: 0 0 0 3px rgba(5, 50, 32, 0.08);
}
.field-input.error { border-color: #B43D3D !important; }
.field-input[readonly] { background: #F0EFEA; color: var(--text-muted); cursor: default; }
.field-input.prefilled {
  background: #F2F8F4;
  border-color: var(--color-sage);
}

.field-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}

/* Select wrapper */
.field-select-wrap {
  position: relative;
}
.field-select-wrap::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  width: 8px; height: 8px;
  border-right: 1.5px solid var(--color-forest);
  border-bottom: 1.5px solid var(--color-forest);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.field-select-wrap select {
  padding-right: 36px;
  cursor: pointer;
}

/* ---- Accessibility: visually hidden inputs inside styled labels ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   RADIO GROUP
   ============================================================ */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.radio-group.row { flex-direction: row; flex-wrap: wrap; gap: 8px; }

.radio {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border: 1.5px solid var(--border-default);
  border-radius: 10px;
  background: var(--color-salt);
  cursor: pointer;
  font-size: 14.5px;
  color: var(--color-forest);
  transition: border-color var(--transition-fast);
  user-select: none;
}
.radio:hover { border-color: var(--color-sage); }
.radio.checked {
  border-color: var(--color-forest);
  background: #F2F8F4;
}
.radio.row-pill { padding: 9px 16px; font-size: 14px; }

.rdot {
  width: 18px; height: 18px;
  border-radius: 999px;
  border: 1.5px solid var(--border-default);
  background: var(--color-salt);
  flex-shrink: 0;
  position: relative;
  transition: border-color var(--transition-fast);
}
.radio.checked .rdot { border-color: var(--color-forest); }
.radio.checked .rdot::after {
  content: '';
  width: 9px; height: 9px;
  background: var(--color-forest);
  border-radius: 999px;
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

/* ============================================================
   SECTIONS + CARDS
   ============================================================ */
.section { margin-top: 32px; }

.section-title {
  margin: 0 0 4px;
}
.section-num {
  font-family: var(--font-product);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--color-emerald);
  text-transform: uppercase;
}

.card {
  background: var(--color-salt);
  border: 1.5px solid var(--border-default);
  border-radius: 14px;
  padding: 22px 24px;
}
.card.confirm {
  border-color: var(--color-sage);
  background: linear-gradient(180deg, #F2F8F4 0%, var(--color-salt) 100%);
}
.card.confirm .check {
  width: 36px; height: 36px;
  border-radius: 999px;
  background: var(--color-sage);
  color: var(--color-forest);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---- Confirmation 2-col key/value grid ---- */
.kv-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
}
.kv-2col > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.kv-2col .k {
  font-size: 11px;
  font-family: var(--font-product);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}
.kv-2col .v {
  font-size: 14.5px;
  color: var(--color-forest);
  font-weight: 500;
}
.kv-2col .v.mono {
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 13.5px;
}

.test-chip {
  font-family: var(--font-product);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--color-forest);
  background: rgba(167, 200, 183, 0.30);
  padding: 3px 8px;
  border-radius: 4px;
  line-height: 1.4;
}

/* ---- Summary grid (frozen confirmation) ---- */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 28px;
}
.sg-key {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}
.sg-val {
  font-size: 14.5px;
  color: var(--color-forest);
  font-weight: 500;
  margin-bottom: 6px;
}

/* ============================================================
   BANNERS
   ============================================================ */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 16px;
}
.banner.amber {
  background: #FDF6E3;
  border: 1.5px solid #E8C97A;
  color: #6B4D0E;
}
.banner.success {
  background: #E8F3EC;
  border: 1.5px solid #A7C8B7;
  color: var(--color-forest);
}
.banner.info {
  background: #F2F8F4;
  border: 1.5px solid var(--border-default);
  color: var(--color-forest);
}
.banner .icon { flex-shrink: 0; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.btn-primary-lg {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  background: var(--cta-bg);
  color: var(--cta-text);
  border: none;
  border-radius: 999px;
  padding: 13px 28px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: background-color var(--transition-fast);
  white-space: nowrap;
}
.btn-primary-lg:hover { background: var(--cta-bg-hover); }
.btn-primary-lg:disabled {
  background: #98AAA0;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-ghost-lg {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  color: var(--color-forest);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 13px 12px;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: rgba(5, 50, 32, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-ghost-lg:hover { text-decoration-color: var(--color-forest); }

/* ---- Spinner ---- */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,254,250,0.35);
  border-top-color: var(--color-salt);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   DISCLOSURE / BACK
   ============================================================ */
.disclosure {
  margin-top: 20px;
  text-align: center;
}
.disclosure button {
  appearance: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  font-family: var(--font-body);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.disclosure button:hover { color: var(--color-forest); }

/* ============================================================
   LOCATION PICKER
   ============================================================ */
.location-picker {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 24px;
  align-items: start;
  background: var(--color-salt);
  border: 1.5px solid var(--border-default);
  border-radius: 14px;
  padding: 18px 20px;
  margin-top: 8px;
}
.location-diagram {
  position: relative;
  width: 240px;
  aspect-ratio: 280 / 308;
  flex-shrink: 0;
}
.location-diagram img {
  width: 100%; height: 100%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
.loc-pin {
  position: absolute;
  width: 28px; height: 28px;
  border-radius: 999px;
  background: var(--color-salt);
  border: 1.5px solid var(--color-forest);
  color: var(--color-forest);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-body);
  display: inline-flex;
  align-items: center; justify-content: center;
  cursor: pointer;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 3px rgba(5,50,32,0.15);
  transition: all var(--transition-fast);
  touch-action: manipulation;
}
.loc-pin:hover {
  background: var(--color-metal);
  transform: translate(-50%, -50%) scale(1.08);
}
.loc-pin.selected {
  background: var(--color-forest);
  color: var(--color-salt);
  border-color: var(--color-forest);
  transform: translate(-50%, -50%) scale(1.12);
}
.loc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.loc-btn {
  appearance: none;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  border: 1.5px solid var(--border-default);
  background: var(--color-salt);
  color: var(--color-forest);
  padding: 10px 0;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  touch-action: manipulation;
}
.loc-btn:hover { border-color: var(--color-sage); }
.loc-btn.selected {
  background: var(--color-forest);
  color: var(--color-salt);
  border-color: var(--color-forest);
}
.loc-hint {
  margin-top: 14px;
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.5;
  min-height: 2.5em;
}

/* ============================================================
   MULTI-MATCH LIST
   ============================================================ */
.match-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.match-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--color-salt);
  border: 1.5px solid var(--border-default);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.match-row:hover { border-color: var(--color-sage); }
.match-row.selected { border-color: var(--color-forest); background: #F2F8F4; }
.match-row .m-name { font-size: 15.5px; font-weight: 600; color: var(--color-forest); margin-bottom: 4px; }
.match-row .m-meta {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: center;
}
.match-row .m-meta .pipe { color: rgba(5,50,32,0.2); }
.match-row .m-meta .mono {
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 12.5px;
  color: var(--color-forest);
}
.match-row .m-tests { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.match-row .m-tests .pname {
  font-family: var(--font-product);
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--color-forest);
  background: rgba(167,200,183,0.30);
  padding: 2px 6px; border-radius: 4px;
}
.match-row .m-pick {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px; font-weight: 500;
  color: var(--color-forest);
  white-space: nowrap;
}
.match-row.selected .m-pick { color: var(--color-emerald); }

/* ============================================================
   FROZEN CONFIRMATION HERO
   ============================================================ */
.frozen-hero {
  text-align: center;
  padding: 16px 0 16px;
}
.frozen-hero .check-lg {
  width: 64px; height: 64px;
  border-radius: 999px;
  background: var(--color-sage);
  color: var(--color-forest);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

/* ============================================================
   PRIVACY NOTE
   ============================================================ */
.privacy-note {
  margin-top: 18px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
  background: rgba(167, 200, 183, 0.12);
  border-left: 3px solid var(--color-sage);
  border-radius: 4px;
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  @page { size: letter portrait; margin: 10mm; }

  /* Kill viewport-relative min-heights that force a second blank page */
  html, body, .app { min-height: 0 !important; height: auto !important; }

  /* Collapse screen padding and kill flex-stretch so content fits on one page */
  .page { padding: 0 !important; max-width: 100% !important; flex: none !important; }

  /* Hide interactive chrome */
  .app-header .kit-badge, .btn-row, .btn-ghost-lg,
  .disclosure, .app-footer, .step-pills { display: none !important; }

  /* Tighten card for print */
  .card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    padding: 14px 16px !important;
  }

  /* Scale down the location diagram so it doesn't push onto a second page */
  .loc-diagram-print { max-width: 130px !important; }

  /* Tighten summary grid rows */
  .summary-grid { gap: 10px !important; }
  .summary-grid .sg-key { font-size: 11px !important; }
  .summary-grid .sg-val { font-size: 13px !important; }

  /* Prevent orphaned page breaks inside key blocks */
  .card, .summary-grid > div { break-inside: avoid; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 700px) {
  .app-header { padding: 12px 20px; }
  .app-header .kit-badge { font-size: 11px; padding: 5px 10px 5px 8px; }

  .page { padding: 24px 20px 48px; }

  .h-display { font-size: 28px; }
  .h-display.sm { font-size: 24px; }

  .field-grid-2 { grid-template-columns: 1fr; }
  .kv-2col { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr; }

  .location-picker {
    grid-template-columns: 1fr;
  }
  .location-diagram {
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
  }

  .btn-row { flex-direction: column; align-items: stretch; }
  .btn-primary-lg { justify-content: center; }

  .step-pills { gap: 6px; font-size: 10px; }
  .step-pill .bar { width: 16px; }

  .match-row { grid-template-columns: 1fr; }
  .match-row .m-pick { margin-top: 8px; }
}
