/* YHORIZON-JM purchase sheet. Product inventory lives in the shared order API. */

[hidden] { display: none !important; }

.buy-page {
  background: var(--paper);
  padding-top: var(--nav-h, 68px);
}

.buy-skip:focus { position: fixed; }

/* Masthead: same shell height and lockup as the company portal. */
.buy-header {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  background: var(--paper);
}
.buy-header__inner {
  width: min(calc(100% - 2 * var(--page-gutter)), var(--max));
  height: var(--nav-h);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.buy-header nav {
  display: flex;
  align-items: center;
  gap: 24px;
}
.buy-header nav a {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.buy-header nav a:hover,
.buy-header nav a[aria-current="page"] { color: var(--ink); }
.buy-header nav a[aria-current="page"] {
  padding-bottom: 5px;
  background: var(--horizon);
  background-repeat: no-repeat;
  background-size: 100% 2px;
  background-position: left bottom;
}
.buy-header__back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Page */
.buy-main {
  width: min(calc(100% - 2 * var(--page-gutter)), var(--max));
  margin-inline: auto;
  padding: 52px 0 clamp(72px, 10vh, 120px);
}
.buy-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--ink);
}
.buy-intro h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 4.8rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -.045em;
}
.buy-intro p {
  max-width: 54ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}
.buy-intro__meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .06em;
  white-space: nowrap;
}
.buy-intro__meta strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}

.buy-intro__meta a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-left: 5px;
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 13px;
  letter-spacing: 0;
  text-decoration: underline;
  text-underline-offset: .25em;
}

.buy-layout {
  display: grid;
  grid-template-columns: minmax(0, .94fr) minmax(0, 1.06fr);
  grid-template-rows: min-content auto;
  grid-template-areas: "photo checkout" "serial checkout";
  gap: 24px clamp(32px, 4.5vw, 68px);
  align-items: start;
  padding-top: clamp(30px, 4vw, 48px);
}

/* Product plate */
.buy-figure {
  grid-area: photo;
  margin: 0;
  border-top: 2px solid var(--red);
  background: var(--dark);
  color: var(--silk);
}
.buy-figure img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: 42% 48%;
}
.serial-preview {
  grid-area: serial;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  scroll-margin-top: calc(var(--nav-h) + 20px);
}

.serial-preview__stage {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  margin-top: 14px;
  background: #e4e2de;
  border: 1px solid var(--line);
}

.serial-preview h2 { margin: 0; font-size: 19px; }
.serial-preview p { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.serial-preview__plate {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(14px, 3vw, 28px);
}

.serial-preview__plate img {
  display: block;
  width: min(100%, 240px);
  height: auto;
  box-shadow: 0 8px 20px rgb(23 23 25 / .16);
}

.serial-preview__stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  visibility: hidden;
  touch-action: pan-y !important;
  cursor: grab;
}

.serial-preview__stage canvas[data-ready="true"] { visibility: visible; }
.serial-preview__stage canvas:active { cursor: grabbing; }
.serial-preview .serial-preview__caption { font-size: 13px; }

.serial-preview__tools { display: flex; flex-wrap: wrap; gap: 2px 16px; }
.serial-preview__tools button {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  text-decoration: underline;
  text-underline-offset: .25em;
  cursor: pointer;
}
.serial-preview__tools button:hover { color: var(--yh-red); }
.serial-preview__tools button:disabled { color: var(--muted); cursor: wait; }

/* Order sheet */
.buy-panel {
  grid-area: checkout;
  min-width: 0;
  padding-top: 2px;
}
.buy-summary-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.buy-summary-head h2 {
  margin: 0;
  max-width: 16ch;
  font-size: clamp(1.45rem, 2.3vw, 2rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.03em;
}
.buy-summary-head p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.buy-price {
  flex: 0 0 auto;
  margin: 0;
  text-align: right;
}
.buy-price strong {
  display: block;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1;
  letter-spacing: -.045em;
}
.buy-price span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.buy-addons {
  margin: 0;
  padding: 18px 0 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
}
.buy-addons legend {
  padding: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
}
.buy-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  font-size: 14px;
}
.buy-option b {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Promo */
.buy-promo {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}
.buy-promo__head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}
.buy-promo label {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
}
.buy-promo small {
  color: var(--muted);
  font-size: 11px;
}
.buy-promo__row {
  display: flex;
  gap: 8px;
  margin-top: 9px;
}
.buy-promo__row input {
  flex: 1;
  min-width: 0;
}
.buy-promo__row button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  font: 600 12px/1 var(--font-sans);
  cursor: pointer;
}
.buy-promo__row button:hover { border-color: var(--ink); }
.buy-promo__status {
  min-height: 18px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}
.buy-promo__status.is-ok { color: var(--red); }
.buy-promo__status.is-error { color: #a51624; }

/* Fields */
.buy-fields {
  margin: 0;
  padding: 22px 0 4px;
  border: 0;
}
.buy-fields legend {
  padding: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
}
.buy-fields__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px 14px;
  margin-top: 12px;
}
.buy-field { display: grid; gap: 6px; }
.buy-field--wide { grid-column: 1 / -1; }
.buy-field label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}
.buy-field label small {
  color: var(--muted);
  font-weight: 400;
}
.buy-field input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--paper-hi);
  color: var(--ink);
  font: 400 14px/1.5 var(--font-sans);
}
.buy-field input:hover { border-color: var(--ink-soft); }
.buy-field input:focus-visible {
  border-color: var(--red);
  outline: 2px solid var(--red);
  outline-offset: -1px;
}
.buy-field input::placeholder { color: var(--muted); }

/* Totals */
.buy-totals {
  margin: 24px 0 0;
  border-top: 1px solid var(--ink);
}
.buy-totals > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.buy-totals dt { color: var(--muted); }
.buy-totals dd {
  margin: 0;
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.buy-totals .buy-total {
  padding: 16px 0 0;
  border-bottom: 0;
  font-size: 15px;
}
.buy-totals .buy-total dt { color: var(--ink); font-weight: 700; }
.buy-totals .buy-total dd {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.04em;
}
.buy-discount dd { color: var(--red); }

.buy-submit {
  display: flex;
  width: 100%;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}
.buy-status {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.buy-status.is-error { color: #a51624; }
.buy-small {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.65;
}

/* Receipt */
.buy-receipt {
  max-width: 780px;
  margin: 0 auto;
  padding-top: clamp(28px, 4vw, 48px);
}
.buy-receipt[hidden] { display: none; }
.buy-receipt__head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--ink);
}
.buy-receipt h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: -.04em;
}
.buy-receipt__head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.buy-status-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid var(--red);
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.buy-receipt__id {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.buy-receipt__id code {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 15px;
  word-break: break-all;
}
.buy-receipt__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}
.buy-receipt__actions .btn {
  min-height: 42px;
  padding: 0 15px;
}
.buy-receipt__note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

/* Footer */
.buy-footer {
  margin-top: 0;
}

@media (max-width: 860px) {
  .buy-main { padding-top: 34px; }
  .buy-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-template-areas: "photo" "checkout" "serial";
    gap: 28px;
  }
  .buy-figure img { aspect-ratio: 16 / 9; }
  .buy-intro { grid-template-columns: 1fr; gap: 14px; }
  .buy-intro__meta { justify-content: flex-start; }
}

@media (max-width: 640px) {
  .buy-header__inner { gap: 12px; }
  .buy-header nav { gap: 14px; }
  .buy-header nav a { font-size: 12px; }
  .buy-header nav a:first-child { display: none; }
  .buy-main { padding-bottom: 64px; }
  .buy-intro h1 { font-size: clamp(1.7rem, 8vw, 2.8rem); }
  .buy-intro p { font-size: 14px; }
  .buy-summary-head { gap: 14px; }
  .buy-summary-head h2 { font-size: 1.35rem; }
  .buy-price strong { font-size: 2rem; }
  .buy-fields__grid { grid-template-columns: 1fr; }
  .buy-receipt__head { flex-direction: column; gap: 12px; }
  .buy-receipt__actions { display: grid; grid-template-columns: 1fr 1fr; }
  .buy-receipt__actions .btn { justify-content: center; }
}

@media (max-width: 380px) {
  .buy-header nav a { font-size: 11px; }
  .buy-header nav { gap: 10px; }
}


/* Quantity is part of the order, including one matching set of selected addons per unit. */
.buy-quantity-row { display:flex; justify-content:space-between; align-items:center; gap:20px; padding:20px 0; border-bottom:1px solid var(--line); }
.buy-quantity-row>label { font-size:14px; font-weight:700; }
.buy-quantity { display:grid; grid-template-columns:42px 65px 42px; border:1px solid var(--line); }
.buy-quantity button { min-height:44px; padding:0; border:0; background:transparent; color:var(--ink); font:inherit; font-size:22px; font-weight:500; line-height:1; cursor:pointer; }
.buy-quantity button:hover:not(:disabled) { background:var(--paper-lo,#e7e3db); }
.buy-quantity button:disabled { color:#aaa4a3; cursor:default; }
.buy-quantity input { appearance:textfield; -moz-appearance:textfield; width:100%; min-width:0; min-height:44px; border:0; border-inline:1px solid var(--line); background:transparent; color:var(--ink); text-align:center; font:inherit; font-size:16px; font-variant-numeric:tabular-nums; }
.buy-quantity input::-webkit-inner-spin-button,.buy-quantity input::-webkit-outer-spin-button { -webkit-appearance:none; margin:0; }
.buy-quantity :focus-visible { outline:2px solid var(--accent,var(--red)); outline-offset:2px; }
.buy-addon-unit { margin-left:12px; font-size:12px; font-weight:400; letter-spacing:0; color:var(--muted); }
.buy-addons legend { display:flex; flex-wrap:wrap; align-items:baseline; }
@media(max-width:440px){.buy-quantity{grid-template-columns:42px 58px 42px}.buy-addon-unit{margin-left:10px}}

.buy-summary-head>div,.buy-figure,.buy-field { min-width:0; }
.buy-fields__grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
@media(max-width:860px){.buy-fields__grid { grid-template-columns:minmax(0,1fr); }}
