/**
 * @file components.css
 * @description Reusable Nova Soul UI components (v0.2).
 *
 * Depends on: css/tokens.css, css/base.css.
 * Loaded by: every HTML page.
 * Behaviour: js/components.js and the modules it starts.
 *
 * Naming: .ns-block, .ns-block__element, .ns-block--variant.
 * Each component sets only its own internals; spacing BETWEEN components
 * belongs to the page layout, which prevents specificity fights.
 *
 * House rules (checked by tools/check-design-tokens.ts):
 *   - every value comes from tokens.css: no hex/rgb colours, no hand-written shadows;
 *   - one block per component: change the block, never append an override later;
 *   - no #id selectors and no !important.
 */

/* =====================================================================
 * Mark + wordmark
 * ===================================================================== */
.ns-mark {
  width: var(--mark-size, 2.5rem);
  aspect-ratio: 1;
  color: var(--color-ornament);
  flex: none;
}

/* The single orchestrated motion moment: the compass settles to north. */
.ns-mark--settle {
  animation: ns-settle var(--duration-settle) var(--ease-settle) both;
}

@keyframes ns-settle {
  from {
    opacity: 0;
    transform: rotate(-28deg) scale(0.96);
  }
  to {
    opacity: 1;
    transform: rotate(0) scale(1);
  }
}

.ns-wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text);
  font-family: var(--font-display);
  font-weight: var(--weight-medium);
  font-size: var(--text-s);
  letter-spacing: var(--tracking-wordmark);
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}

/* =====================================================================
 * Buttons. One shape (pill) and two heights for the whole site.
 * Markup: <a class="ns-button ns-button--primary">, add --secondary for the
 * outline style, --compact for bars and headers, --block for full width.
 * ===================================================================== */
.ns-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--button-height);
  padding: var(--space-2) var(--button-padding-inline);
  border: 1px solid transparent;
  border-radius: var(--button-radius);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--duration-quick) ease, border-color var(--duration-quick) ease;
}

.ns-button--primary {
  background: var(--color-inverse-bg);
  color: var(--color-inverse-text);
}

.ns-button--primary:hover {
  background: var(--color-inverse-hover);
}

.ns-button--secondary {
  border-color: var(--color-line-strong);
  background: transparent;
  color: var(--color-text);
}

.ns-button--secondary:hover {
  border-color: var(--color-text);
  background: var(--color-surface);
}

.ns-button--compact {
  min-height: var(--button-height-compact);
  padding: var(--space-1) var(--space-4);
  font-size: var(--text-s);
}

.ns-button--block {
  width: 100%;
}

.ns-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  pointer-events: none;
}

/* A button that carries a price spreads label and price apart. */
.ns-button:has(.ns-button__price) {
  justify-content: space-between;
  gap: var(--space-6);
}

.ns-button__price {
  font-family: var(--font-display);
  font-size: var(--text-l);
  font-weight: var(--weight-medium);
  font-variant-numeric: lining-nums;
  color: var(--color-inverse-text);
}

/* Round icon-only button (menu, close, previous/next). */
.ns-icon-button {
  display: grid;
  place-items: center;
  width: var(--field-height);
  aspect-ratio: 1;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-round);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
}

.ns-icon-button:hover:not(:disabled) {
  border-color: currentColor;
}

.ns-icon-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.ns-icon-button svg {
  width: 1rem;
  height: 1rem;
}

/* A text-styled button, for "edit these details myself" and "cancel". */
.ns-textlink {
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-link);
  font: inherit;
  font-size: var(--text-s);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

/* =====================================================================
 * Eyebrow: small uppercase label above a title, price or card.
 * Used by .pg-card, the footer headings and the report (same values).
 * ===================================================================== */
.ns-eyebrow {
  font-family: var(--font-text);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--color-link);
}

/* =====================================================================
 * Meridian: step indicator derived from the logo's dotted cardinal line.
 * Dots grow toward the current step; the current step wears the pendant ring.
 * Markup: <ol class="ns-meridian"> <li data-state="done|current|todo">
 * ===================================================================== */
.ns-meridian {
  --dot: 0.4rem;
  display: grid;
  grid-template-columns: repeat(var(--steps, 4), 1fr);
  padding: 0;
  list-style: none;
  counter-reset: none;
}

.ns-meridian__step {
  position: relative;
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  font-size: var(--text-s);
  color: var(--color-text-muted);
  text-align: center;
}

/* Dotted connector from the previous step's centre to this one. */
.ns-meridian__step + .ns-meridian__step::before {
  content: "";
  position: absolute;
  top: calc(0.8125rem - 1px);
  right: 50%;
  width: 100%;
  height: 2px;
  background: radial-gradient(circle, var(--color-ornament) 0.9px, transparent 1.1px) left center / 7px 2px repeat-x;
  z-index: 0;
}

.ns-meridian__dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 1.625rem;
  aspect-ratio: 1;
  border-radius: var(--radius-round);
  background: var(--color-bg);
}

.ns-meridian__dot::after {
  content: "";
  width: var(--dot);
  aspect-ratio: 1;
  border-radius: inherit;
  background: var(--color-ornament);
}

.ns-meridian__step[data-state="done"] .ns-meridian__dot::after {
  --dot: 0.55rem;
}

.ns-meridian__step[data-state="todo"] .ns-meridian__dot::after {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--color-ornament);
}

.ns-meridian__step[data-state="current"] {
  color: var(--color-text);
}

.ns-meridian__step[data-state="current"] .ns-meridian__dot {
  box-shadow: inset 0 0 0 1px var(--color-ornament);
}

.ns-meridian__step[data-state="current"] .ns-meridian__dot::after {
  --dot: 0.7rem;
  background: var(--color-text);
}

/* Narrow screens: only the current label stays visible. */
@media (max-width: 36rem) {
  .ns-meridian__step:not([data-state="current"]) .ns-meridian__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

/* =====================================================================
 * Product choice: one panel, rows divided by a hairline (not twin cards).
 * The radio is drawn as the logo's pendant: ring + centre dot.
 * ===================================================================== */
.ns-choice-group {
  min-width: 0;
  padding: 0;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-panel);
  overflow: hidden;
}

.ns-choice {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background-color var(--duration-quick) ease;
}

.ns-choice + .ns-choice {
  border-top: var(--border-hairline);
}

.ns-choice:has(.ns-choice__input:checked) {
  background: var(--color-surface);
}

.ns-choice__input {
  appearance: none;
  width: 1.5rem;
  aspect-ratio: 1;
  margin-top: 0.2rem;
  border: 1px solid var(--color-ornament);
  border-radius: var(--radius-round);
  background: transparent;
  cursor: pointer;
}

.ns-choice__input:checked {
  background: radial-gradient(circle, var(--color-text) 0 31%, transparent 34%);
}

.ns-choice__name {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-l);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
}

.ns-choice__meta {
  display: block;
  font-size: var(--text-s);
  color: var(--color-text-muted);
}

.ns-choice__price {
  display: grid;
  justify-items: end;
  text-align: right;
}

.ns-choice__price-label {
  font-size: var(--text-xs);
  color: var(--color-link);
}

.ns-price {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-light);
  font-variant-numeric: lining-nums;
  line-height: 1;
}

@media (max-width: 30rem) {
  .ns-choice {
    grid-template-columns: auto 1fr;
  }

  .ns-choice__price {
    grid-column: 2;
    justify-items: start;
    text-align: left;
  }
}

/* =====================================================================
 * Form field. One height everywhere (--field-height). Errors appear only
 * after the person has interacted (:user-invalid) or after js/order-form.js
 * marked the field (.is-invalid), never on page load.
 * ===================================================================== */
.ns-field {
  display: grid;
  gap: var(--space-2);
  max-width: 24rem;
}

.ns-field--wide {
  grid-column: 1 / -1;
}

.ns-field__label {
  font-weight: var(--weight-medium);
}

.ns-field__help {
  font-size: var(--text-s);
  color: var(--color-text-muted);
  line-height: 1.45;
}

.ns-field__input {
  min-height: var(--field-height);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-control);
  background: var(--color-field);
  font-variant-numeric: lining-nums tabular-nums;
}

textarea.ns-field__input {
  min-height: 7rem;
  resize: vertical;
}

.ns-field__input:hover {
  border-color: var(--color-text);
}

.ns-field__input:focus-visible {
  border-color: var(--color-text);
  outline-offset: 1px;
}

.ns-field__error {
  display: none;
  font-size: var(--text-s);
  color: var(--color-error);
}

.ns-field:has(.ns-field__input:user-invalid) .ns-field__input,
.ns-field.is-invalid .ns-field__input {
  border-color: var(--color-error);
}

.ns-field:has(.ns-field__input:user-invalid) .ns-field__error,
.ns-field.is-invalid .ns-field__error {
  display: block;
}

/* A visitor who tries to continue gets the first gaps pulsed three times (js/order-form.js
 * restarts the animation on every attempt); the red border then stays until it is fixed.
 * --duration-pulse is 0ms under prefers-reduced-motion, which leaves only the border. */
@keyframes ns-invalid-pulse {
  50% {
    box-shadow: var(--shadow-invalid);
  }
}

@keyframes ns-invalid-pulse-inset {
  50% {
    box-shadow: var(--shadow-invalid-inset);
  }
}

.ns-field.is-invalid .ns-field__input {
  animation: ns-invalid-pulse var(--duration-pulse) ease-in-out 3;
}

.ns-field.is-invalid .ns-check input {
  outline: 2px solid var(--color-error);
  outline-offset: 2px;
  animation: ns-invalid-pulse var(--duration-pulse) ease-in-out 3;
}

.ns-choice-group.is-invalid {
  border-color: var(--color-error);
  animation: ns-invalid-pulse-inset var(--duration-pulse) ease-in-out 3;
}

.ns-field__aside {
  font-size: var(--text-s);
  justify-self: start;
}

.ns-field__status {
  min-height: 1.2em;
  font-size: var(--text-s);
  color: var(--color-text-muted);
}

/* Checkbox row. Consent text flows as one paragraph, links included. */
.ns-check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
}

.ns-check input {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.2rem;
  accent-color: var(--color-text);
}

.ns-check > span:not(.ns-check__label) {
  display: grid;
  gap: var(--space-1);
}

.ns-check__label {
  display: block;
  line-height: 1.5;
}

.ns-check__label a {
  color: var(--color-link);
}

/* =====================================================================
 * Arch: illustration framed as an arched window, echoing the oval
 * vignettes in the Nova Soul illustrations.
 * ===================================================================== */
.ns-arch {
  position: relative;
  display: grid;
  justify-items: center;
}

.ns-arch__image {
  width: 100%;
  aspect-ratio: 924 / 1180;
  object-fit: cover;
  object-position: center 20%;
  border-radius: 50% 50% var(--radius-panel) var(--radius-panel) / 36% 36% var(--radius-panel) var(--radius-panel);
  background: var(--color-surface);
}

/* The compass mark hangs on the arch like the pendant under the logo. */
.ns-arch__pendant {
  --mark-size: 5.5rem;
  margin-block-start: calc(var(--mark-size) / -2);
  padding: var(--space-2);
  border-radius: var(--radius-round);
  background: var(--color-bg);
  box-sizing: content-box;
}

/* =====================================================================
 * Shelf: horizontal scroll-snap row (report pages, soul animals).
 * Works with touch, trackpad and keyboard; js/shelf.js adds buttons.
 * ===================================================================== */
.ns-shelf {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--shelf-item, 16rem);
  gap: var(--space-3);
  padding: var(--space-2) var(--space-1) var(--space-5);
  list-style: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--space-1);
  scrollbar-width: thin;
  scrollbar-color: var(--color-ornament) transparent;
}

.ns-shelf > * {
  scroll-snap-align: start;
}

.ns-shelf-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* =====================================================================
 * Report preview: contents list (styled like the report's own contents
 * page, with dotted leaders) + a cover stack that opens the reader.
 * ===================================================================== */
.ns-report {
  display: grid;
  grid-template-columns: minmax(15rem, 1fr) minmax(0, 2.3fr);
  gap: var(--space-7);
  align-items: start;
}

@media (max-width: 52rem) {
  .ns-report {
    grid-template-columns: minmax(0, 1fr);
  }
}

:where(.ns-report__intro) > * + * {
  margin-block-start: var(--space-4);
}

.ns-report__note {
  font-size: var(--text-s);
  color: var(--color-text-muted);
}

.ns-report__chapters {
  margin-block-start: var(--space-6);
  padding: 0;
  list-style: none;
}

.ns-report__chapter {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding-block: var(--space-2);
  color: var(--color-text);
  text-decoration: none;
}

.ns-report__chapter::after {
  content: "";
  order: 1;
  flex: 1;
  border-bottom: 1px dotted var(--color-ornament);
}

.ns-report__chapter-number {
  order: 2;
  font-size: var(--text-s);
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--color-text-muted);
}

.ns-report__chapter:hover .ns-report__chapter-name,
.ns-report__chapter[aria-current="true"] .ns-report__chapter-name,
.ns-report__chapter[aria-current="true"] .ns-report__chapter-number {
  color: var(--color-link);
}

/* Cover stack: the sample report as a small pile of paper, opening the reader. */
.ns-report__cover {
  position: relative;
  display: block;
  width: min(100%, 22rem);
  margin-inline: auto;
  isolation: isolate;
}

.ns-report__cover::before,
.ns-report__cover::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: var(--radius-control);
  background: var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-line);
  transition: transform var(--duration-quick) ease;
}

.ns-report__cover::before {
  transform: rotate(-5deg) translate(-4%, 1%);
}

.ns-report__cover::after {
  transform: rotate(3deg) translate(3%, 2%);
}

.ns-report__cover:hover::before {
  transform: rotate(-8deg) translate(-8%, 1%);
}

.ns-report__cover:hover::after {
  transform: rotate(6deg) translate(7%, 2%);
}

.ns-report__cover img {
  width: 100%;
  aspect-ratio: 924 / 1316;
  object-fit: cover;
  border-radius: var(--radius-control);
  box-shadow: 0 0 0 1px var(--color-line), var(--shadow-object);
}

.ns-report__actions {
  margin-block-start: var(--space-6);
}

/* =====================================================================
 * Soul animal figure (inside a shelf)
 * ===================================================================== */
.ns-animal {
  display: grid;
  gap: var(--space-3);
}

.ns-animal img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius-panel);
  background: var(--color-surface);
}

.ns-animal figcaption {
  font-family: var(--font-display);
  font-size: var(--text-l);
  font-weight: var(--weight-medium);
  line-height: var(--leading-display);
}

/* =====================================================================
 * Card deck: front card with the previous and next card behind it.
 * Positions are set by js/card-deck.js through data-pos.
 * ===================================================================== */
.ns-deck {
  --deck-card: clamp(13rem, 58vw, 21rem);
  position: relative;
  margin-block: var(--space-6) 0;
  outline-offset: var(--space-3);
  touch-action: pan-y;
  user-select: none;
  overflow-x: clip;
  overflow-clip-margin: var(--space-4);
}

.ns-deck__track {
  position: relative;
  display: grid;
  place-items: center;
  height: calc(var(--deck-card) * 1.5 + var(--space-7));
  margin: 0;
  padding: 0;
  list-style: none;
}

.ns-deck__card {
  position: absolute;
  width: var(--deck-card);
  aspect-ratio: 2 / 3;
  cursor: pointer;
  transition:
    transform var(--duration-deck) var(--ease-settle),
    opacity var(--duration-deck) var(--ease-settle),
    filter var(--duration-deck) var(--ease-settle);
  will-change: transform;
}

.ns-deck__card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4.5% / 3%;
  box-shadow: var(--shadow-object);
  pointer-events: none;
}

.ns-deck__card[data-pos="0"] {
  z-index: 3;
  cursor: grab;
  transform: none;
}

.ns-deck__card[data-pos="-1"],
.ns-deck__card[data-pos="1"] {
  z-index: 2;
  opacity: 0.92;
  filter: saturate(0.85) brightness(0.97);
}

.ns-deck__card[data-pos="-1"] {
  transform: translateX(-58%) scale(0.84) rotate(-5deg);
}

.ns-deck__card[data-pos="1"] {
  transform: translateX(58%) scale(0.84) rotate(5deg);
}

.ns-deck__card[data-pos="-2"],
.ns-deck__card[data-pos="2"] {
  z-index: 1;
  opacity: 0;
  pointer-events: none;
}

.ns-deck__card[data-pos="-2"] {
  transform: translateX(-90%) scale(0.7) rotate(-8deg);
}

.ns-deck__card[data-pos="2"] {
  transform: translateX(90%) scale(0.7) rotate(8deg);
}

.ns-deck__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
}

.ns-deck__status {
  min-width: 7rem;
  font-size: var(--text-s);
  font-variant-numeric: lining-nums tabular-nums;
  text-align: center;
  color: var(--color-text-muted);
}

/* =====================================================================
 * Kompaskaart flip card
 * Markup: partials/compass-card.html · Behaviour: js/compass-card.js
 * Both faces are photographs of the printed card, rendered to the same shape, so
 * they sit in one grid cell and nothing jumps while the card turns.
 * ===================================================================== */
.ns-flipcard {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
}

.ns-flipcard__card {
  display: block;
  width: min(100%, 22rem);
  padding: 0;
  border: 0;
  background: none;
  perspective: 1400px;
  cursor: pointer;
}

.ns-flipcard__inner {
  display: grid;
  transform-style: preserve-3d;
  transition: transform var(--duration-turn) var(--ease-settle);
}

.ns-flipcard__card[data-flipped] .ns-flipcard__inner {
  transform: rotateY(180deg);
}

.ns-flipcard__face {
  grid-area: 1 / 1;
  overflow: hidden;
  border-radius: var(--radius-panel);
  backface-visibility: hidden;
  box-shadow: var(--shadow-object);
}

.ns-flipcard__face img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-panel);
}

.ns-flipcard__face--back {
  transform: rotateY(180deg);
}

.ns-flipcard__hint {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-s);
  color: var(--color-text-muted);
}

.ns-flipcard__icon {
  width: 1rem;
  height: 1rem;
  flex: none;
}

.ns-flipcard__card:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 6px;
  border-radius: var(--radius-panel);
}

/* No 3D turn for visitors who asked for less motion: the faces simply swap. */
@media (prefers-reduced-motion: reduce) {
  .ns-deck__card {
    transition: none;
  }

  .ns-flipcard__inner,
  .ns-flipcard__card[data-flipped] .ns-flipcard__inner {
    transform: none;
    transition: none;
  }

  .ns-flipcard__face {
    backface-visibility: visible;
  }

  .ns-flipcard__face--back {
    transform: none;
    visibility: hidden;
  }

  .ns-flipcard__card[data-flipped] .ns-flipcard__face--front {
    visibility: hidden;
  }

  .ns-flipcard__card[data-flipped] .ns-flipcard__face--back {
    visibility: visible;
  }
}

/* =====================================================================
 * Reviews: one testimonial at a time on a forest card; all reviews share
 * one grid cell, so the tallest sets a stable reading height.
 * Markup: partials/reviews.html · Behaviour: js/reviews.js
 * ===================================================================== */
.ns-reviews {
  --review-interval: 12s; /* keep in step with js/reviews.js */
  display: block;
  margin-block-start: var(--space-5);
}

.ns-reviews__track {
  display: grid;
  touch-action: pan-y;
}

.ns-review {
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  min-height: 15rem;
  margin: 0;
  padding: var(--space-6) var(--space-5);
  border-radius: var(--radius-panel);
  background: var(--color-inverse-bg);
  color: var(--color-inverse-text);
  text-align: center;
}

/* Inside the rotating track only the active review is visible (as before v0.2). */
.ns-reviews__track .ns-review {
  grid-area: 1 / 1;
  visibility: hidden;
  pointer-events: none;
}

.ns-reviews__track .ns-review[data-active] {
  visibility: visible;
  pointer-events: auto;
}

.ns-review__quote p {
  font-family: var(--font-display);
  font-size: var(--text-l);
  font-style: italic;
  line-height: var(--leading-quote);
}

.ns-review__by {
  display: grid;
  font-size: var(--text-s);
}

.ns-review__name {
  font-weight: var(--weight-medium);
}

.ns-review__stars {
  font-size: var(--text-l);
  letter-spacing: var(--tracking-eyebrow);
}

.ns-reviews__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-block-start: var(--space-4);
}

.ns-reviews__status {
  display: none;
}

.ns-reviews__dots {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ns-reviews__dot {
  width: 0.5rem;
  height: 0.5rem;
  border: 1px solid currentColor;
  border-radius: var(--radius-round);
  background: transparent;
  cursor: pointer;
}

.ns-reviews__dot[aria-current="true"] {
  background: currentColor;
}

.ns-reviews__progress {
  width: min(100%, 18rem);
  height: 3px;
  margin: var(--space-3) auto 0;
  border-radius: var(--radius-round);
  background: var(--color-line-strong);
  overflow: hidden;
}

.ns-reviews__progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--color-text);
}

.ns-reviews[data-review-running] .ns-reviews__progress-fill {
  animation: ns-review-progress var(--review-interval) linear forwards;
}

@keyframes ns-review-progress {
  to {
    width: 100%;
  }
}

/* =====================================================================
 * Page dialog: terms or privacy on top of a form (js/page-dialog.js)
 * ===================================================================== */
.ns-page-dialog {
  width: min(48rem, 100% - 2rem);
  max-height: min(88dvh, 60rem);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-panel);
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-overlay);
}

.ns-page-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.ns-page-dialog::backdrop {
  background: var(--color-scrim-strong);
}

.ns-page-dialog__bar {
  display: flex;
  justify-content: flex-end;
  padding: var(--space-3) var(--space-3) 0;
}

.ns-page-dialog__body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-block-end: var(--space-6);
}

.ns-page-dialog__body .pg-section {
  padding-block: var(--space-4);
}

.ns-page-dialog__body .pg-section__inner {
  width: auto;
  margin-inline: var(--space-6);
}

/* =====================================================================
 * Order form (order + gift card). Checkout is intentionally denser than
 * editorial pages: one decision per screen, tighter gaps and smaller help
 * text, but the same field and button sizes as everywhere else.
 * Markup: partials/order-form.html, partials/giftcard-form.html
 * Behaviour: js/order-form.js
 * ===================================================================== */
.ns-order {
  max-width: 52rem;
}

.ns-order .ns-field {
  gap: var(--space-1);
  max-width: none;
  min-width: 0;
}

.ns-order .ns-field__help,
.ns-order .ns-field__error,
.ns-order .ns-field__status {
  font-size: var(--text-xs);
  line-height: 1.3;
}

.ns-order textarea.ns-field__input {
  min-height: 6rem;
}

.ns-order__progress {
  margin-block-end: var(--space-4);
}

/* The dots already communicate visual progress. Keep step names for assistive
 * technology without repeating the visible fieldset title. */
.ns-order__progress .ns-meridian__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.ns-order__step {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.ns-order__title {
  margin-block-end: var(--space-2);
  padding: 0;
  font-family: var(--font-display);
  font-size: var(--text-l);
  font-weight: var(--weight-light);
}

.ns-order__grid,
.ns-order__birth-fields,
.ns-order__gift-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: var(--space-3) var(--space-4);
}

.ns-order__birth-fields,
.ns-order__gift-fields,
.ns-order__conditional {
  grid-column: 1 / -1;
}

.ns-order__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3);
  margin-block-start: var(--space-3);
}

.ns-order__actions > :only-child {
  margin-inline-start: auto;
}

.ns-order__actions--quiet {
  justify-content: flex-start;
  margin-block-start: 0;
}

/* The primary action stays in reach at the bottom of long steps. */
.ns-order__actions--sticky {
  position: sticky;
  bottom: 0;
  z-index: 22;
  margin-inline: calc(-1 * var(--space-3));
  margin-block-end: calc(-1 * var(--space-3));
  padding: var(--space-3);
  background: linear-gradient(to bottom, transparent, var(--color-bg) 25%);
}

.ns-order__pay { flex: 1 1 auto; }
.ns-order__consents { display: grid; gap: var(--space-4); scroll-margin-block: 8rem; }
.ns-order__consents .ns-field { scroll-margin-block: 8rem; }
.ns-order__step[data-step="review"] > .ns-order__actions { flex-wrap: nowrap; }
.ns-order__step[data-step="review"] > .ns-order__actions .ns-button { min-width: 0; padding-inline: clamp(.75rem, 2vw, 1.5rem); }
.ns-order__step[data-step="review"] .ns-order__pay { gap: var(--space-2); }
.ns-order__step[data-step="review"] .ns-button__price { white-space: nowrap; }


/* Coupon field with its Apply button and the preview status (js/order-form.js, only
 * when config checkout.promotionPreview is true). */
.ns-promo {
  display: flex;
  gap: var(--space-2);
  align-items: stretch;
}

.ns-promo .ns-field__input {
  flex: 1 1 auto;
  min-width: 0;
}

.ns-promo .ns-button {
  flex: none;
}

.ns-promo__status[data-state="error"] {
  color: var(--color-error);
}

/* The order is one persistent object (js/order-form.js builds it): where you are, what is
 * done, what you order, the total and the button to continue. Phone and tablet: a sticky bar
 * that opens the same panel. Desktop: a sticky column beside the step. */
.ns-order__rail {
  position: sticky;
  top: 0;
  z-index: 21;
  margin-block-end: var(--space-3);
  background: var(--color-bg);
  border-bottom: var(--border-hairline);
}

.ns-order__bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.125rem var(--space-3);
  width: 100%;
  padding: var(--space-2) 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.ns-order__bar-step,
.ns-order__bar-toggle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.ns-order__bar-toggle {
  grid-column: 2;
  grid-row: 1;
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.ns-order__bar-line {
  display: flex;
  grid-column: 1 / -1;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-s);
}

.ns-order__bar-product {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ns-order__bar-price,
.ns-order__panel-amount {
  flex: none;
  font-variant-numeric: lining-nums tabular-nums;
}

.ns-order__panel {
  display: none;
  gap: var(--space-4);
  padding-block-end: var(--space-4);
  border-top: var(--border-hairline);
}

.ns-order__rail[data-open] .ns-order__panel {
  display: grid;
  max-height: min(70dvh, 34rem);
  overflow: auto;
}

@media (max-width: 59.999rem) {
  /* Only the compact order bar follows the visitor. An opened order is normal
   * page content, so it cannot float over the progress dots or form fields. */
  .ns-order__rail[data-open] {
    position: static;
  }

  .ns-order__rail[data-open] .ns-order__panel {
    max-height: none;
    overflow: visible;
  }
}

.ns-order__panel > * {
  margin: 0;
}

.ns-order__panel-title {
  padding-block-start: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-l);
  font-weight: var(--weight-light);
}

.ns-order__panel-steps {
  display: grid;
  gap: var(--space-2);
  padding: 0;
  list-style: none;
}

.ns-order__panel-steps li {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: start;
}

.ns-order__panel-steps li[data-state="todo"] {
  color: var(--color-text-muted);
}

.ns-order__panel-mark {
  display: grid;
  place-items: center;
  width: 1.375rem;
  aspect-ratio: 1;
  border: 1px solid var(--color-ornament);
  border-radius: var(--radius-round);
  font-size: var(--text-xs);
}

.ns-order__panel-steps li[data-state="done"] .ns-order__panel-mark {
  background: var(--color-ornament);
  color: var(--color-bg);
}

.ns-order__panel-steps li[data-state="current"] .ns-order__panel-mark {
  background: var(--color-inverse-bg);
  border-color: var(--color-inverse-bg);
  color: var(--color-inverse-text);
}

.ns-order__panel-copy {
  display: grid;
  min-width: 0;
}

.ns-order__panel-copy strong {
  font-weight: var(--weight-medium);
}

.ns-order__panel-copy small {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}

.ns-order__panel-lines {
  display: grid;
  gap: var(--space-2);
  padding-block-start: var(--space-3);
  border-top: var(--border-hairline);
}

.ns-order__panel-line {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  margin: 0;
}

.ns-order__panel-line--discount .ns-order__panel-amount {
  color: var(--color-link);
}

.ns-order__panel-line--total {
  padding-block-start: var(--space-2);
  border-top: var(--border-hairline);
  font-family: var(--font-display);
  font-size: var(--text-l);
}

.ns-order__panel-cta {
  width: 100%;
}

/* Keep a field that gets focus out from under the bar and the action bar. */
.ns-order .ns-field__input,
.ns-order .ns-check input,
.ns-order .ns-choice__input {
  scroll-margin-block: 6rem;
}

@media (min-width: 60rem) {
  .ns-order[data-order-type="order"]:has(.ns-order__rail) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 23rem;
    column-gap: var(--space-6);
    align-items: start;
    max-width: 72rem;
  }

  .ns-order[data-order-type="order"]:has(.ns-order__rail) > * {
    grid-column: 1;
  }

  .ns-order[data-order-type="order"] > .ns-order__rail {
    grid-column: 2;
    grid-row: 1 / span 6;
    top: var(--space-5);
    align-self: start;
    max-height: calc(100dvh - var(--space-6));
    overflow: auto;
    margin: 0;
    padding: var(--space-4);
    border: 1px solid var(--color-ornament-soft);
    border-radius: var(--radius-panel);
    background: var(--color-tint);
  }

  .ns-order__bar {
    display: none;
  }

  .ns-order__panel,
  .ns-order__rail[data-open] .ns-order__panel {
    display: grid;
    max-height: none;
    overflow: visible;
    padding-block-end: 0;
    border-top: 0;
  }

  .ns-order__panel-title {
    padding-block-start: 0;
  }

  /* The panel lists every step, so the separate progress row is not needed here. */
  .ns-order[data-order-type="order"]:has(.ns-order__rail) .ns-order__progress {
    display: none;
  }
}

.ns-order__note,
.ns-order__state {
  font-size: var(--text-s);
  color: var(--color-text-muted);
}

.ns-order__failure {
  font-size: var(--text-s);
  color: var(--color-error);
}

.ns-order__credit {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.ns-order__review {
  display: grid;
  grid-template-columns: minmax(8rem, auto) minmax(0, 1fr);
  gap: 0 var(--space-5);
  border-top: var(--border-hairline);
}

.ns-order__review dt,
.ns-order__review dd {
  margin: 0;
  padding-block: var(--space-3);
  border-bottom: var(--border-hairline);
}

.ns-order__review dt {
  font-size: var(--text-s);
  color: var(--color-text-muted);
}

/* Long identifiers such as e-mail addresses must stay inside checkout summaries. */
.ns-order__review dd {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 30rem) {
  .ns-order__review {
    grid-template-columns: minmax(0, 1fr);
  }

  .ns-order__review dt {
    padding-block-end: 0;
    border-bottom: 0;
  }
}

.ns-order-summary {
  max-width: 40rem;
  margin-block: var(--space-6);
  padding: var(--space-5) var(--space-6);
  border: 1px solid var(--color-ornament);
  border-radius: var(--radius-panel);
  background: var(--color-tint);
}

.ns-order-summary__title {
  margin-block-end: var(--space-3);
  font-size: var(--text-l);
}

/* ---- Birth place search -------------------------------------------- */
.ns-suggest {
  position: relative;
}

.ns-suggest__list {
  position: absolute;
  z-index: 20;
  inset-inline: 0;
  margin: var(--space-1) 0 0;
  padding: var(--space-1);
  max-height: 16rem;
  overflow-y: auto;
  list-style: none;
  background: var(--color-bg);
  border: var(--border-hairline);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-raised);
}

.ns-suggest__item {
  min-height: var(--field-height);
  padding: var(--space-2) var(--space-3);
  touch-action: manipulation;
  border-radius: var(--radius-control);
  font-size: var(--text-s);
  cursor: pointer;
}

.ns-suggest__item:hover,
.ns-suggest__item:focus-visible {
  background: var(--color-surface);
  outline: none;
}

.ns-place-row {
  display: grid;
  gap: var(--space-3);
}

/* The resolved country, coordinates and time zone, so the visitor can check them. */
.ns-place__resolved {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-2) var(--space-3);
  border: var(--border-hairline);
  border-radius: var(--radius-panel);
  font-size: var(--text-s);
  color: var(--color-text-muted);
}

@media (min-width: 48rem) {
  .ns-place-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .ns-place-row .ns-place__resolved {
    margin-block-end: 0;
    max-width: 29rem;
  }
}

/* ---- Payment step: summary on top, Stripe fields below -------------- */
.ns-order:has(.ns-pay) {
  max-width: 56rem;
}

.ns-pay {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

.ns-pay__main {
  display: grid;
  gap: var(--space-5);
  min-width: 0;
}

.ns-pay__payment {
  display: grid;
  gap: var(--space-4);
}

.ns-pay__subtitle {
  font-family: var(--font-display);
  font-size: var(--text-l);
  font-weight: var(--weight-light);
}

/* Stripe mounts its own iframe here; it must not sit inside another iframe. */
.ns-pay__element {
  min-height: 3rem;
}

.ns-pay__shipping {
  display: grid;
  gap: var(--space-4);
  padding-block-start: var(--space-4);
  border-block-start: var(--border-hairline);
}

.ns-pay__shipping > [data-shipping-fields] {
  display: grid;
  gap: var(--space-4);
}

.ns-pay__summary {
  order: -1;
  align-self: start;
  padding: 0;
  border: var(--border-hairline);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  overflow: hidden;
}

.ns-pay__summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  list-style: none;
}

.ns-pay__summary-head::-webkit-details-marker {
  display: none;
}

.ns-pay__summary-head::after {
  content: "+";
  flex: none;
  margin-inline-start: var(--space-2);
  color: var(--color-link);
}

.ns-pay__summary[open] .ns-pay__summary-head::after {
  content: "−";
}

.ns-pay__summary-copy {
  display: grid;
  min-width: 0;
  gap: 0.1rem;
}

.ns-pay__summary-copy > strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ns-pay__summary-copy > span {
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ns-pay__summary > .ns-order__review {
  margin: 0 var(--space-4) var(--space-4);
}

.ns-pay__total {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  margin-block-start: var(--space-4);
  padding-block-start: var(--space-4);
  border-block-start: var(--border-hairline);
  font-size: var(--text-l);
}

.ns-checkout-compass {
  width: var(--text-m);
  height: var(--text-m);
  flex: none;
}

.ns-checkout-compass__needle {
  transform-origin: center;
  transform-box: view-box;
  animation: ns-compass-turn 2.4s linear infinite;
}

@keyframes ns-compass-turn {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .ns-checkout-compass__needle { animation: none; }
}

/* While Stripe is confirming, the whole step reads as busy. */
.ns-order[aria-busy="true"] .ns-pay {
  opacity: 0.6;
  pointer-events: none;
}

/* =====================================================================
 * Contact form. Markup: partials/contact-form.html
 * ===================================================================== */
.ns-contact-form {
  display: grid;
  gap: var(--space-4);
  max-width: 48rem;
  margin-block-start: var(--space-5);
}

.ns-contact-form__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: var(--space-4);
}

.ns-contact-form .ns-field {
  max-width: none;
}

/* Persistent contact feedback, visible in the viewport until dismissed. */
.ns-notice {
  --notice-accent: var(--color-text);
  position: fixed;
  inset-inline-end: var(--space-4);
  bottom: max(var(--space-4), env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: min(30rem, calc(100vw - 2 * var(--space-4)));
  padding: var(--space-4);
  border: var(--border-hairline);
  border-inline-start: var(--space-1) solid var(--notice-accent);
  border-radius: var(--radius-panel);
  background: var(--color-surface-raised);
  color: var(--color-text);
  box-shadow: var(--shadow-raised);
}

.ns-notice[data-state="error"] {
  --notice-accent: var(--color-error);
}

.ns-notice__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: var(--space-6);
  height: var(--space-6);
  border-radius: var(--radius-round);
  background: color-mix(in srgb, var(--notice-accent) 12%, transparent);
  color: var(--notice-accent);
  font-weight: var(--weight-medium);
}

.ns-notice__message {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: var(--text-s);
  overflow-wrap: anywhere;
}

.ns-notice__close {
  display: grid;
  place-items: center;
  flex: none;
  min-width: var(--field-height);
  min-height: var(--field-height);
  padding: 0;
  border: 0;
  border-radius: var(--radius-round);
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--text-l);
  cursor: pointer;
}

/* Website-owned location inputs share the order form's sizing and typography. */
.ns-pay__payment, .ns-pay__element { min-width: 0; }
[data-digital-address] { display: grid; gap: var(--space-4); width: 100%; min-width: 0; max-width: 100%; }
[data-digital-address] .ns-field { min-width: 0; width: 100%; max-width: none; }
[data-digital-address] .ns-field__input { box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; font: inherit; color: var(--color-text); }
[data-digital-address] .ns-field__status { overflow-wrap: anywhere; }
[data-digital-address] .ns-field__input[aria-invalid="true"] { border-color: var(--color-error); }
