/* ═══════════════════════════════════════════════════════════════════════════
   BASE — reset, element defaults, typography.

   Element selectors only. No components, no utilities. Loaded after tokens.css
   and before the legacy custom.css.
   ═══════════════════════════════════════════════════════════════════════════ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Anchored sections must clear the fixed top bar */
  scroll-padding-top: calc(var(--topbar-h) + var(--space-4));
  -webkit-tap-highlight-color: transparent;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-normal);
  color: var(--text-secondary);
  background-color: var(--surface-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-synthesis-weight: none;
  font-optical-sizing: auto;
  overflow-wrap: break-word;
}


/* ─── Headings ──────────────────────────────────────────────────────────────
   Display face, tight tracking that tightens further as size grows. Margins
   are bottom-only so vertical rhythm is owned by the flow, not by collapsing
   margin pairs. */

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  margin-top: 0;
  margin-bottom: var(--space-3);
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  color: var(--text-primary);
  text-wrap: balance;
}

h1, .h1 { font-size: var(--fs-3xl); letter-spacing: var(--ls-tighter); }
h2, .h2 { font-size: var(--fs-2xl); letter-spacing: var(--ls-tight); }
h3, .h3 { font-size: var(--fs-xl);  letter-spacing: var(--ls-tight); }
h4, .h4 { font-size: var(--fs-lg);  letter-spacing: var(--ls-normal); }
h5, .h5 { font-size: var(--fs-md);  letter-spacing: var(--ls-normal); font-weight: var(--fw-semibold); }
h6, .h6 { font-size: var(--fs-ui);  letter-spacing: var(--ls-wide); font-weight: var(--fw-semibold); }


/* ─── Text elements ─────────────────────────────────────────────────────── */

p {
  margin-top: 0;
  margin-bottom: var(--space-4);
}

p:last-child,
ul:last-child,
ol:last-child {
  margin-bottom: 0;
}

small, .small {
  font-size: var(--fs-sm);
}

strong, b {
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
}

hr {
  margin: var(--space-6) 0;
  border: 0;
  border-top: 1px solid var(--border-subtle);
  opacity: 1;
}

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  padding: 0.15em 0.4em;
  color: var(--bd-teal-400);
  background: var(--surface-4);
  border-radius: var(--radius-xs);
}

pre {
  padding: var(--space-4);
  overflow-x: auto;
  color: var(--text-secondary);
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

pre code {
  padding: 0;
  background: none;
}

kbd {
  display: inline-block;
  min-width: 1.55em;
  padding: 0.15em 0.4em;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  line-height: 1.4;
  color: var(--text-secondary);
  text-align: center;
  background: var(--surface-4);
  border: 1px solid var(--border-default);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
}

blockquote {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-4);
  color: var(--text-tertiary);
  border-left: 2px solid var(--border-brand);
}

abbr[title] {
  text-decoration-color: var(--text-muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  cursor: help;
}

::selection {
  color: var(--text-primary);
  background: var(--brand-subtle-hi);
}


/* ─── Links ─────────────────────────────────────────────────────────────── */

a {
  color: var(--brand);
  text-decoration: none;
  transition: var(--transition-colors);
}

a:hover {
  color: var(--brand-hover);
}

/* Prose links keep their underline — it is the affordance. Component links
   (nav, buttons, cards) opt out via their own rules. */
.prose a,
p > a,
li > a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.prose a:hover,
p > a:hover,
li > a:hover {
  text-decoration-color: currentColor;
}


/* ─── Lists ─────────────────────────────────────────────────────────────── */

ul, ol {
  margin-top: 0;
  margin-bottom: var(--space-4);
  padding-left: var(--space-5);
}

li + li {
  margin-top: var(--space-1);
}

/* Structural lists carry no marker */
nav ul,
nav ol,
[role="list"],
.list-unstyled,
.list-plain {
  padding-left: 0;
  list-style: none;
}


/* ─── Media ─────────────────────────────────────────────────────────────── */

img, svg, video, canvas, audio, iframe, embed, object {
  display: block;
  vertical-align: middle;
}

img, video {
  max-width: 100%;
  height: auto;
}

img {
  /* No background-color here.
     It was set to --surface-3 so a broken or slow image would not flash white on
     a dark surface — but a background on <img> also paints *behind transparent
     pixels*, so every transparent PNG (the logo, breeder marks) rendered inside
     a visible rectangle wherever the surrounding surface was darker.
     Broken images are handled instead by the capture-phase error listener in
     app.js, which swaps in the placeholder. */
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

svg {
  fill: currentColor;
}


/* ─── Forms ─────────────────────────────────────────────────────────────── */

button, input, optgroup, select, textarea {
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

button, [type="button"], [type="reset"], [type="submit"] {
  -webkit-appearance: button;
  appearance: button;
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  min-height: 4.5rem;
}

label {
  display: inline-block;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  float: left;
  width: 100%;
  margin-bottom: var(--space-2);
  padding: 0;
  font-size: var(--fs-ui);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
}

legend + * {
  clear: left;
}

/* Native date/time pickers ship a dark-on-dark glyph in Chrome */
::-webkit-calendar-picker-indicator {
  filter: invert(0.85);
  cursor: pointer;
  opacity: 0.65;
  transition: opacity var(--dur-fast) var(--ease-out);
}

::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

/* Chrome's autofill wash is unreadable on dark surfaces */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--text-primary);
  -webkit-box-shadow: 0 0 0 100px var(--surface-4) inset;
  caret-color: var(--text-primary);
}

/* Strip the spinner from number inputs — steppers belong to the component */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

input[type="range"] {
  accent-color: var(--brand);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--brand);
}

progress {
  accent-color: var(--brand);
}


/* ─── Tables ────────────────────────────────────────────────────────────── */

table {
  border-collapse: collapse;
  border-spacing: 0;
}

caption {
  padding: var(--space-2) 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  text-align: left;
}

th {
  text-align: inherit;
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
}

/* Tabular figures keep numeric columns aligned regardless of digit width */
td:has(> .num),
.num,
.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}


/* ─── Focus ─────────────────────────────────────────────────────────────────
   Ring only for keyboard users. Never remove it — this is the single most
   commonly broken accessibility affordance in a redesign. */

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Elements that supply their own ring via box-shadow opt out of the outline */
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
  outline: none;
}


/* ─── Details / summary ─────────────────────────────────────────────────── */

summary {
  cursor: pointer;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}


/* ─── Scrollbars ────────────────────────────────────────────────────────── */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--bd-neutral-650) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bd-neutral-650);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--bd-neutral-600);
  background-clip: padding-box;
}

::-webkit-scrollbar-corner {
  background: transparent;
}


/* ─── Accessibility helpers ─────────────────────────────────────────────── */

.visually-hidden,
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Skip link — visible only once focused */
.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-max);
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-ui);
  font-weight: var(--fw-semibold);
  color: var(--text-on-brand);
  background: var(--brand);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  transform: translateY(-200%);
  transition: transform var(--dur-normal) var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}


/* ─── Print ─────────────────────────────────────────────────────────────────
   The theme prints invoices, certificates, ID cards and QR sheets, so print
   has to produce ink-on-white rather than a dark screenshot. */

@media print {
  :root {
    --surface-base: #fff;
    --surface-1: #fff;
    --surface-2: #fff;
    --surface-3: #fff;
    --surface-4: #fff;
    --surface-5: #fff;
    --text-primary: #000;
    --text-secondary: #1a1a1a;
    --text-tertiary: #333;
    --text-muted: #555;
    --border-subtle: #ccc;
    --border-default: #999;
    --border-strong: #666;
    --shadow-xs: none;
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
    --shadow-xl: none;
    --shadow-2xl: none;
    --highlight-top: none;
    --highlight-top-strong: none;
  }

  body {
    color: #000;
    background: #fff;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  /* Screen-only chrome must not consume paper */
  .app-sidebar,
  .app-topbar,
  .app-subbar,
  .floating-feedback-btns,
  #hb-btn,
  #hb-box,
  #global-cart-float-wrap,
  .share-bar,
  .no-print,
  nav.pagination,
  .pagination,
  footer,
  .site-footer {
    display: none !important;
  }

  .app-main,
  .app-content {
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Never split a record across pages */
  .card,
  .panel,
  .detail-card,
  tr,
  figure {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  h1, h2, h3, h4 {
    page-break-after: avoid;
    break-after: avoid;
  }
}
