/* ==========================================================================
   Kaidora — forms.css
   Forms, basket and checkout. Loaded after site.css, so it may refine the
   shared primitives (.field, .form-grid, .checkbox, .qty) without touching
   the design-system stylesheet.

   Contents
   01. Shared form polish
   02. Contact and newsletter
   03. Bespoke commission form
   04. Basket
   05. Checkout
   06. Commission terms and thank-you pages
   07. Small screens and reduced motion
   ========================================================================== */

/* 01. Shared form polish --------------------------------------------------- */

.form-grid {
  align-items: start;
}

.form-grid > .field,
.form-grid > * {
  min-width: 0;
}

/* Labels can carry an optional "(optional)" note; let that wrap instead of
   pushing the label sideways on a narrow column. */
.field__label,
label.field__label {
  align-items: baseline;
  flex-wrap: wrap;
  line-height: 1.35;
}

/* Helper copy belongs to the field, not to the page rhythm: removing its
   bottom margin stops labels and inputs from colliding. */
.field > .muted,
.field > .field__hint {
  margin: 0;
  color: var(--text-3);
  font-size: 0.82rem;
  line-height: 1.5;
}

.input,
.select,
.textarea {
  max-width: 100%;
}

.checkbox {
  min-width: 0;
}

.checkbox > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.checkbox > input {
  margin-top: 0.2rem;
}

.form-error {
  margin: 0;
}

/* Server validation lists are injected into .flash by the contact and
   commission routes; restore markers that the global list reset removed. */
.flash ul {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
  list-style: disc;
}

.flash li + li {
  margin-top: 0.25rem;
}

/* 02. Contact and newsletter ----------------------------------------------- */

.contact-page .contact-details {
  display: grid;
  gap: 0.35rem;
  margin: var(--s-sm) 0 var(--s-md);
  padding: 0;
  font-style: normal;
}

.contact-details p {
  margin: 0;
  line-height: 1.6;
}

.contact-details strong {
  display: inline-block;
  min-width: 4.4rem;
  color: var(--text-3);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.contact-form {
  display: grid;
  gap: var(--s-sm);
  padding: clamp(1rem, 3vw, 1.75rem);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.contact-form .form-grid {
  gap: var(--s-sm) var(--s-md);
}

.contact-form .form-actions,
.contact-form .form-note {
  margin: 0;
}

.contact-form .form-note {
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-3);
}

.contact-form .textarea {
  min-height: 11rem;
}

.newsletter-signup {
  margin-top: var(--s-lg);
}

.newsletter-form {
  display: grid;
  gap: 0.85rem;
  align-items: end;
  margin-top: var(--s-sm);
}

.newsletter-form .field {
  max-width: none;
}

.newsletter-form .form-actions {
  margin: 0;
}

.newsletter-signup__note {
  margin-top: var(--s-sm);
  font-size: 0.82rem;
  line-height: 1.55;
}

@media (min-width: 640px) {
  .newsletter-form {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

/* 03. Bespoke commission form --------------------------------------------- */

.commission-form {
  gap: var(--s-md);
}

.commission-form > .form-actions,
.commission-form > .form-note {
  margin: 0;
}

.form-section {
  display: grid;
  gap: var(--s-sm);
  padding: clamp(1rem, 2.6vw, 1.9rem);
}

.form-section > * {
  min-width: 0;
}

.form-section > legend {
  width: 100%;
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.form-section > .muted {
  max-width: 68ch;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
}

.form-section > .form-grid {
  margin: 0;
}

.commission-form .field .textarea {
  min-height: 8.5rem;
}

.checkbox-group {
  display: grid;
  gap: 0.8rem;
}

/* The shape cards are real radios inside a wrapping label. The input covers
   the whole card (transparent), so the card must carry the visible focus
   ring — the native control itself is intentionally invisible. */
.shape-cards {
  grid-template-columns: repeat(auto-fit, minmax(8.25rem, 1fr));
  gap: 0.65rem;
}

.shape-card {
  min-width: 0;
}

.shape-card__input {
  inline-size: 100%;
  block-size: 100%;
  margin: 0;
}

.shape-card__body {
  padding: 0.9rem 1rem;
}

.shape-card__label {
  font-size: 0.95rem;
  line-height: 1.3;
}

.shape-card:focus-within {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

.shape-card:has(.shape-card__input:focus-visible) {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

/* 04. Basket --------------------------------------------------------------- */

.cart-page__head .lede {
  margin: 0;
}

.cart-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-md);
  align-items: start;
}

.cart-list {
  display: grid;
  gap: var(--s-sm);
  min-width: 0;
}

.cart-line {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 0.9rem;
  align-items: start;
  padding: 0.9rem;
}

.cart-line__media {
  inline-size: 76px;
}

.cart-line__body {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.cart-line__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.2rem 0.75rem;
  min-width: 0;
}

.cart-line__title {
  min-width: 0;
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
  line-height: 1.3;
}

.cart-line__title a {
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.cart-line__title a:hover {
  color: var(--accent-text);
}

.cart-line__total {
  margin: 0;
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cart-line__options {
  margin: 0;
  color: var(--text-3);
  font-size: 0.82rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.cart-line__price {
  margin: 0;
  color: var(--text-2);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.cart-line__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  margin-top: 0.35rem;
}

.cart-line__qty {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.cart-line__update {
  flex: 0 0 auto;
}

.cart-line__remove-form {
  display: flex;
  align-items: center;
}

.cart-line__remove {
  font-size: 0.82rem;
}

.cart-totals {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.cart-totals h2 {
  margin: 0 0 0.5rem;
}

.cart-totals .discount-form {
  display: grid;
  gap: 0.45rem;
  margin: var(--s-sm) 0;
}

.cart-totals .discount-form .field__label {
  margin: 0;
}

.discount-form__row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  min-width: 0;
}

.discount-form__row .input {
  flex: 1 1 auto;
  min-width: 0;
}

.discount-form__row .btn {
  flex: 0 0 auto;
}

.discount-form .form-note {
  margin: 0;
  color: var(--text-3);
  font-size: 0.75rem;
  line-height: 1.45;
}

.cart-totals__checkout {
  margin-top: 0.25rem;
}

.cart-totals__note {
  margin-top: 0.35rem;
  font-size: 0.76rem;
  line-height: 1.45;
}

.cart-empty {
  display: grid;
  justify-items: center;
  gap: var(--s-sm);
  padding: clamp(2rem, 6vw, 4rem) var(--s-md);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  text-align: center;
}

.cart-empty h2 {
  margin: 0;
  font-size: var(--fs-h3);
}

.cart-empty p {
  max-width: 42ch;
  margin: 0;
  color: var(--text-2);
}

@media (min-width: 560px) {
  .cart-line {
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 1.1rem;
    padding: 1rem;
  }

  .cart-line__media {
    inline-size: 96px;
  }
}

@media (min-width: 900px) {
  .cart-layout {
    grid-template-columns: minmax(0, 1.55fr) minmax(20rem, 0.85fr);
    gap: var(--s-lg);
  }

  .cart-totals {
    position: sticky;
    top: calc(var(--header-h) + 1rem);
  }
}

/* 05. Checkout ------------------------------------------------------------- */

.checkout-page__head {
  max-width: 60rem;
}

.checkout-page__head .lede {
  margin-bottom: 0;
}

/* Base: one column, summary after the form (the natural reading order on a
   phone, so Place order is the last thing after the terms). */
.checkout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-md);
  align-items: start;
}

.checkout__main {
  display: grid;
  gap: var(--s-sm);
  min-width: 0;
}

.checkout__section {
  display: grid;
  gap: var(--s-sm);
  min-width: 0;
  padding: clamp(1rem, 2.6vw, 1.75rem);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.checkout__section > h2 {
  margin: 0;
  font-size: var(--fs-h3);
}

.checkout__section p.muted {
  margin: 0;
  font-size: 0.85rem;
}

.checkout__section .form-grid {
  gap: 0.95rem var(--s-sm);
}

.checkout__section .pay-note {
  margin: 0;
}

.checkout__section .checkbox {
  margin: 0;
}

.checkout__summary {
  display: grid;
  gap: var(--s-sm);
  order: 0;
  position: static;
  top: auto;
  min-width: 0;
  padding: clamp(1rem, 2.6vw, 1.6rem);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  box-shadow: var(--sh-2);
}

.checkout__summary h2 {
  margin: 0;
  font-size: var(--fs-h3);
}

.checkout__items {
  display: grid;
  gap: 0.7rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.checkout__items li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  line-height: 1.45;
}

.checkout__items li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.checkout__item-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.checkout__item-qty {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.checkout__item-options {
  display: block;
  margin-top: 0.1rem;
  color: var(--text-3);
  font-size: 0.78rem;
}

.checkout__item-price {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.checkout__totals {
  display: grid;
  padding-top: 0.15rem;
  border-top: 1px solid var(--line-2);
}

.checkout__discount {
  display: inline-flex;
  align-items: baseline;
  gap: 0.08rem;
  color: var(--ok-text);
}

.checkout__ship-name {
  color: var(--text-3);
  font-size: 0.8rem;
}

.checkout__submit {
  margin-top: 0.2rem;
}

.checkout__note {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: center;
}

.shipping-options {
  display: grid;
  gap: 0.7rem;
  margin: 0;
}

.shipping-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
  min-width: 0;
  padding: 0.9rem 1rem;
}

.shipping-option input {
  margin-top: 0.2rem;
}

.shipping-option__body {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.shipping-option__note {
  display: block;
  color: var(--text-3);
  font-size: 0.8rem;
  line-height: 1.45;
}

.shipping-option__price {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.shipping-option:has(input:focus-visible) {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Two real columns at >= 1000px: form on the left, sticky order on the
   right. Everything below 1000px is the single column above. */
@media (min-width: 1000px) {
  .checkout {
    grid-template-columns: minmax(0, 1.42fr) minmax(21rem, 0.82fr);
    gap: var(--s-lg);
  }

  .checkout__summary {
    position: sticky;
    top: calc(var(--header-h) + 1.25rem);
    order: 0;
  }

  .checkout__items {
    max-height: 15rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 0.25rem;
  }
}

/* 06. Commission terms and thank-you pages --------------------------------- */

.terms-page__intro {
  margin-bottom: var(--s-sm);
}

.terms-card {
  padding: clamp(1rem, 3vw, 2rem);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.terms-card .prose {
  max-width: 100%;
}

.terms-card .prose > * + * {
  margin-top: var(--s-sm);
}

.terms-page .form-actions {
  margin-top: var(--s-md);
}

.thank-you-page h1 {
  margin-bottom: 0.6rem;
}

.request-summary {
  display: grid;
  gap: 0;
  margin: var(--s-md) 0;
  padding: 0 clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.request-summary__row {
  display: grid;
  grid-template-columns: minmax(7rem, auto) minmax(0, 1fr);
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.request-summary__row:last-child {
  border-bottom: 0;
}

.request-summary dt {
  padding-top: 0.15rem;
  color: var(--text-3);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.request-summary dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.next-steps {
  display: grid;
  gap: 0.55rem;
  padding-left: 1.4rem;
  list-style: decimal;
}

.next-steps li {
  padding-left: 0.25rem;
}

.next-steps li::marker {
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
}

.order-panel {
  margin-top: var(--s-md);
}

.order-items li {
  align-items: flex-start;
}

.order-items__name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.order-items__price {
  white-space: nowrap;
}

.summary-list li > :first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.summary-list li > :last-child {
  white-space: nowrap;
}

/* 07. Small screens and reduced motion ------------------------------------- */

@media (max-width: 480px) {
  .request-summary__row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.2rem;
  }

  .checkout__summary {
    padding: 1rem;
  }

  .checkout__items li {
    font-size: 0.88rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .shape-card,
  .shipping-option,
  .cart-line {
    transition: none;
  }
}

/* Commission waitlist / closed book */
.commission-closed {
  margin-top: var(--s-xl);
  padding: clamp(1.4rem, 3vw, 2.4rem);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  background: var(--surface-solid);
}
.commission-closed h2 { margin: 0.4rem 0 0.7rem; font-size: var(--fs-h2); }
.commission-closed .lede { max-width: 46rem; }
.commission-waitlist {
  display: grid;
  gap: var(--s-sm);
  max-width: 34rem;
  margin-top: var(--s-md);
}
.commission-waitlist .btn { justify-self: start; }
