/**
 * =============================================================================
 * HIPHEN DIGITAL PHENOTYPING — Base Styles
 * =============================================================================
 * Global reset + base element styles.
 * NO component styles here. NO hardcoded values.
 * ALL values reference tokens from variables.css (the single source of truth).
 * =============================================================================
 */

/* ---------------------------------------------------------------------------
 * FONTS, all self-hosted (audit 2026-09-30)
 * ---------------------------------------------------------------------------
 * Gilroy is declared by theme.json `fontFace` (assets/fonts/Gilroy-*.woff, converted from the TTF sources) and
 * printed by WordPress in <head>; the former @font-face block here pointed at
 * .woff2 files that never existed (one 404 per page) and has been removed.
 *
 * Montserrat (the `--font-inter` secondary face) used to load from Google
 * Fonts. It is now the same variable font Google serves, split by script:
 * the browser downloads only the subset a page needs (latin ≈ 37 KB).
 * --------------------------------------------------------------------------- */
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('../fonts/Montserrat-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('../fonts/Montserrat-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------------------------------------------------------------------------
 * RESET
 * --------------------------------------------------------------------------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ---------------------------------------------------------------------------
 * HTML & BODY
 * --------------------------------------------------------------------------- */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-inter);
  font-size: var(--text-md);
  font-weight: var(--fw-regular);
  line-height: var(--lh-loose);
  background-color: var(--color-dark);
  color: var(--color-white);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------------------------------------------------------------------------
 * TYPOGRAPHY — Headings
 * ---------------------------------------------------------------------------
 * NO `text-transform: capitalize` ON A TITLE. Ever.
 *
 * It capitalises EVERY word, which is precisely what Title Case forbids for
 * articles, prepositions, conjunctions and "to" — the Solutions hero read
 * "Imaging Solutions For Phenotyping" on screen while the stored copy said
 * "for". Twenty-two title rules across the theme carried it and every one of
 * them was silently overriding the editor.
 *
 * Titles are Title Case because they are WRITTEN that way. The four remaining
 * `capitalize` rules in the theme are on data labels (crop names, an event's
 * month) where the source is a single term, not a sentence.
 * --------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-gilroy);
  font-weight: var(--fw-bold);
  line-height: var(--lh-snug);
  color: var(--color-white);
}

h1 {
  font-size: var(--text-4xl);
  line-height: var(--lh-tight);
}

h2 {
  font-size: var(--text-3xl);
  line-height: var(--lh-snug);
}

h3 {
  font-size: var(--text-2xl);
}

h4 {
  font-size: var(--text-xl);
}

/* ---------------------------------------------------------------------------
 * LINKS
 * --------------------------------------------------------------------------- */
a {
  color: var(--color-white);
  text-decoration: none;
  transition: color var(--transition-base);
}

a:hover,
a:focus-visible {
  color: var(--color-light-green);
}

a:focus-visible {
  outline: 2px solid var(--color-light-green);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---------------------------------------------------------------------------
 * IMAGES
 * --------------------------------------------------------------------------- */
img,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ---------------------------------------------------------------------------
 * LISTS
 * --------------------------------------------------------------------------- */
ul, ol {
  list-style: none;
}

/* ---------------------------------------------------------------------------
 * BUTTONS (base reset — component styles in component files)
 * --------------------------------------------------------------------------- */
button {
  cursor: pointer;
  font-family: var(--font-gilroy);
  border: none;
  background: transparent;
  color: inherit;
}

button:focus-visible {
  outline: 2px solid var(--color-light-green);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------------------
 * FORMS
 * --------------------------------------------------------------------------- */
input,
textarea,
select {
  font-family: var(--font-inter);
  font-size: var(--text-md);
  color: var(--color-white);
  background: transparent;
  border: none;
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--color-white-40);
}

/* ---------------------------------------------------------------------------
 * LAYOUT UTILITIES
 * --------------------------------------------------------------------------- */
/* Site-wide content rail.
 * The effective *visible* content width on desktop must equal
 * --container-content (1200px). Since the container also carries the
 * --padding-x gutter (120px), its outer max-width has to be
 *   content + 2 × gutter = 1440px
 * so that 1200px of content sits inside the gutters.
 * This used to be repeated per page (home / solutions / crops);
 * it is now the single source of truth — every page using .container
 * gets the 1200px-visible rule for free. */
.container {
  max-width: calc(var(--container-content) + 2 * var(--padding-x));
  margin-inline: auto;
  padding-inline: var(--padding-x);
}

.container--wide {
  max-width: var(--container-wide);
  margin-inline: auto;
  padding-inline: var(--padding-x);
}

/* ---------------------------------------------------------------------------
 * SKIP TO CONTENT (accessibility)
 * --------------------------------------------------------------------------- */
.skip-to-content {
  position: absolute;
  top: -100%;
  left: var(--space-8);
  z-index: var(--z-skip-link);
  padding: var(--space-4) var(--space-8);
  background: var(--color-light-green);
  color: var(--color-dark);
  font-family: var(--font-gilroy);
  font-weight: var(--fw-bold);
  font-size: var(--text-base);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  text-decoration: none;
  transition: top var(--transition-fast);
}

.skip-to-content:focus {
  top: 0;
}

/* ---------------------------------------------------------------------------
 * SCREEN READER ONLY
 * --------------------------------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ---------------------------------------------------------------------------
 * RESPONSIVE PADDING
 * --------------------------------------------------------------------------- */
/* Canonical responsive padding for the content rail — matches the
 * pattern previously duplicated in home / solutions / crops. */
@media (max-width: 1023px) {
  .container,
  .container--wide {
    padding-inline: var(--padding-x-md);
  }
}

@media (max-width: 767px) {
  .container,
  .container--wide {
    padding-inline: var(--padding-x-sm);
  }
}

/* ---------------------------------------------------------------------------
 * BACK-TO-TOP BUTTON (.back-to-top)
 * Global pill button injected by hiphen_render_back_to_top_button() in
 * functions.php. Fixed bottom-right, hidden by default (`inert`), revealed
 * once the user has scrolled past ~400px. All visual primitives come from
 * design tokens — same radial-green gradient + double-border pill family
 * as `.btn--primary` and the use-case-card arrow.
 * --------------------------------------------------------------------------- */
.back-to-top {
  position: fixed;
  right: var(--space-12);
  /* Raised above the global Calendly badge widget (fixed bottom-right, ~60px
     tall including its own margin) so the two controls stack instead of
     overlapping. 56px clears the badge with a snug gap. */
  bottom: calc(var(--space-12) + 56px);
  z-index: var(--z-dropdown);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  color: var(--color-white);
  background: var(--gradient-radial-green);
  border: var(--border-pill);
  border-radius: 50%;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity var(--transition-base),
    transform var(--transition-base),
    box-shadow var(--transition-base);
}

.back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-cta);
}

.back-to-top:focus-visible {
  outline: 2px solid var(--color-light-green);
  outline-offset: 3px;
}

.back-to-top__icon {
  width: 20px;
  height: 20px;
}

@media (max-width: 767px) {
  .back-to-top {
    right: var(--space-8);
    /* Same Calendly-badge clearance as desktop, from the smaller mobile base. */
    bottom: calc(var(--space-8) + 56px);
    width: 44px;
    height: 44px;
  }

  .back-to-top__icon {
    width: 18px;
    height: 18px;
  }
}

/* ---------------------------------------------------------------------------
 * "TALK TO AN EXPERT" BADGE — the design system's primary CTA button
 * ---------------------------------------------------------------------------
 * First-party `<a class="hiphen-badge">` printed by functions.php (3a-bis) in
 * wp_footer. It replaced Calendly's injected widget in the 2026-09-30 audit so
 * that no third-party script runs before consent: without consent the link
 * opens Calendly in a new tab, with consent assets/js/calendly.js opens the
 * popup instead. The badge itself is always visible.
 *
 * Rebuilds `.btn.btn--primary.btn--lg.btn--icon` at badge scale. Same
 * construction as assets/css/blocks/btn.css, with a lighter rim because the
 * 48px pill is smaller than the 60px hero CTA. The trailing arrow is the
 * ANGLED arrow-up-right ("this opens something"), as an `::after`.
 * ------------------------------------------------------------------------- */
.hiphen-badge {
  position: fixed;
  right: var(--space-12);
  bottom: var(--space-12);
  z-index: var(--z-dropdown);

  display: inline-flex;
  align-items: center;
  /* 6px rather than the button's 8px: two gaps here (mark → label → arrow). */
  gap: var(--space-3);
  /* 48 − 8 border − 8 padding = the 32px arrow circle. */
  height: 48px;
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-8);
  border-radius: var(--radius-full);

  font-family: var(--font-gilroy);
  font-weight: var(--fw-medium);
  font-size: var(--text-md);
  line-height: 1.25;
  color: var(--color-white);
  text-decoration: none;
  white-space: nowrap;
  /* White on the brand green is a modest ratio; same lift as the hero titles. */
  text-shadow: 0 1px 6px rgba(4, 48, 65, 0.55);

  background: var(--gradient-radial-green);
  /* .btn--icon chrome at lower opacity than the real button (0.18/0.4 →
     0.10/0.22): the 5px rim takes a bigger share of a 48px shape. */
  border: 4px solid rgba(255, 255, 255, 0.10);
  outline: 1px solid rgba(255, 255, 255, 0.22);
  outline-offset: -1px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;

  /* Entrance, then the same expanding lime ring as the 9-dots launcher and the
     counter's live dot. THREE iterations, not infinite: a nudge on arrival. */
  animation:
    hiphen-badge-in 520ms cubic-bezier(0.16, 1, 0.3, 1),
    hiphen-badge-pulse 2.4s ease-out 1.1s 3;
  transition:
    transform var(--transition-base),
    border-color var(--transition-base),
    box-shadow var(--transition-base);
}

@keyframes hiphen-badge-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* The resting shadow is restated in every keyframe so it does not vanish while
   the ring runs. lime-30, not lime-50: a 15px ring starting at half opacity
   read as a solid slab growing out of the badge rather than light dispersing. */
@keyframes hiphen-badge-pulse {
  0% {
    box-shadow: var(--shadow-sm), 0 0 0 0 var(--color-glass-lime-30);
  }
  70% {
    box-shadow: var(--shadow-sm), 0 0 0 15px rgba(143, 191, 72, 0);
  }
  100% {
    box-shadow: var(--shadow-sm), 0 0 0 0 rgba(143, 191, 72, 0);
  }
}

/* --- Leading mark (the wheat emoji) -------------------------------------- */
/* WordPress swaps the character for an <img class="emoji"> with !important
   sizing, so both the raw glyph and the image get the same 20px + lift. */
.hiphen-badge__mark {
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(4, 48, 65, 0.6));
}

.hiphen-badge img.emoji {
  width: 20px !important;
  height: 20px !important;
  margin: 0 !important;
  vertical-align: middle !important;
}

/* --- Trailing arrow: the .btn__icon circle ------------------------------- */
.hiphen-badge::after {
  content: "";
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-circle);
  background-color: var(--color-secondary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17L17 7M17 7H8M17 7V16'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 15px 15px;
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--transition-base),
    background-color var(--transition-base);
}

/* --- Hover / focus: the signature CTA flip ------------------------------- */
/* Green → glass, exactly as .btn--primary:hover, with the arrow circle
   inverting to teal-on-white. `animation: none` stops the ring: the visitor
   found it. */
.hiphen-badge:hover,
.hiphen-badge:focus-visible {
  transform: translateY(-2px);
  background: var(--gradient-radial-glass);
  border-color: rgba(255, 255, 255, 0.26);
  animation: none;
  box-shadow: var(--shadow-glow-cta);
}

.hiphen-badge:focus-visible {
  outline: 2px solid var(--color-white);
  outline-offset: 3px;
}

.hiphen-badge:hover::after,
.hiphen-badge:focus-visible::after {
  background-color: var(--color-white);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23184455' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17L17 7M17 7H8M17 7V16'/%3E%3C/svg%3E");
  /* Travels along its own diagonal, not sideways like the straight arrow. */
  transform: translate(1px, -1px);
}

@media (max-width: 767px) {
  .hiphen-badge {
    right: var(--space-8);
    bottom: var(--space-8);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hiphen-badge {
    animation: none;
  }

  .hiphen-badge:hover,
  .hiphen-badge:hover::after {
    transform: none;
  }
}
