/* Geopolitiks: modal.css (foundation). Buy dialog as an order ledger. */
.modal { position: fixed; inset: 0; z-index: 980; visibility: hidden; }
.modal.is-open { visibility: visible; }
.modal[hidden] { display: none; }
.modal__scrim { position: absolute; inset: 0; background: rgba(2, 3, 5, .78); opacity: 0; transition: opacity .5s var(--ease); }
.modal.is-open .modal__scrim { opacity: 1; }

.modal__sheet {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(640px, 100%);
  background: var(--ink1); border-left: 1px solid var(--line-strong);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .65s var(--ease-io);
}
.modal.is-open .modal__sheet { transform: none; }
.modal__sheet::before { /* ruled-paper hairlines */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(217, 179, 108, .05) 31px 32px);
}
.modal__scroll { position: relative; flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: var(--s6) var(--s6) var(--s5); }
.m-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s5); padding-bottom: var(--s5); border-bottom: 1px solid var(--line); }
.m-title { font-family: var(--f-display); font-weight: 700; font-size: clamp(30px, 5vw, 44px); line-height: 1.05; margin-top: var(--s3); letter-spacing: .01em; }
.m-x { width: 44px; height: 44px; margin: -8px -10px 0 0; display: grid; place-items: center; color: var(--muted); transition: color .3s, transform .4s var(--ease); }
.m-x:hover { color: var(--text); transform: rotate(90deg); }

.m-meta { display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between; gap: var(--s4); padding-block: var(--s4); border-bottom: 1px solid var(--line-soft); }
.m-meta dt { color: var(--dim); margin-bottom: var(--s1); }
.m-meta dd { font-size: 16px; color: var(--text); }
.m-off { color: var(--war) !important; }

.m-notice { display: flex; gap: var(--s4); align-items: flex-start; margin-top: var(--s5); padding: var(--s4); border: 1px solid var(--war); color: var(--text); font-size: 16px; line-height: 1.4; }
.m-notice .ic { margin-top: 3px; color: var(--war); }

.m-sec { margin-top: var(--s6); }
.m-h { padding-bottom: var(--s3); border-bottom: 1px solid var(--line); margin-bottom: 0; }

.ledger__row { border-bottom: 1px solid var(--line-soft); }
.ledger__btn { width: 100%; display: grid; grid-template-columns: 22px minmax(0, auto) minmax(12px, 1fr) auto; align-items: baseline; column-gap: var(--s3); padding: var(--s4) 0; text-align: left; transition: background-color .3s; }
.ledger__btn:hover:not(:disabled) .ledger__name b { color: var(--gold-hi); }
.ledger__box { align-self: center; width: 20px; height: 20px; border: 1px solid var(--line-strong); display: grid; place-items: center; color: transparent; transition: background-color .25s, color .25s, border-color .25s; }
.ledger__box.is-radio { border-radius: 50%; }
.ledger__box .ic { width: 14px; height: 14px; stroke-width: 2; }
.ledger__row.is-on .ledger__box { background: var(--gold); border-color: var(--gold); color: var(--bg); }
.ledger__name { display: flex; flex-direction: column; min-width: 0; }
.ledger__name b { font-weight: 600; font-size: 19px; line-height: 1.2; transition: color .3s; }
.ledger__name i { font-style: normal; font-size: 15px; color: var(--muted); line-height: 1.3; margin-top: 2px; }
.ledger__lead { height: 1px; align-self: center; background: repeating-linear-gradient(to right, var(--line-strong) 0 2px, transparent 2px 6px); opacity: .7; }
.ledger__price { font-size: 19px; color: var(--text); white-space: nowrap; text-align: right; }
.ledger__row.is-off .ledger__name b, .ledger__row.is-off .ledger__price { color: var(--muted); }
.ledger__row.is-off .ledger__btn { cursor: default; }
.m-hint { min-height: 1.4em; margin-top: var(--s3); font-size: 15px; color: var(--gold); }

.m-plat { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }
.m-chip { font-family: var(--f-label); font-size: 13px; letter-spacing: .2em; text-transform: uppercase; font-weight: 600; padding: 11px var(--s4); border: 1px solid var(--line); color: var(--muted); transition: color .3s, border-color .3s, background-color .3s; }
.m-chip:hover { color: var(--text); border-color: var(--line-strong); }
.m-chip.is-on { color: var(--bg); background: var(--gold); border-color: var(--gold); }

.m-foot { position: relative; padding: var(--s5) var(--s6) var(--s6); border-top: 1px solid var(--line-strong); background: var(--ink2); }
.m-line { display: grid; grid-template-columns: auto 1fr auto; column-gap: var(--s3); align-items: baseline; font-size: 17px; padding: 3px 0; color: var(--muted); }
.m-line i { height: 1px; background: repeating-linear-gradient(to right, var(--line) 0 2px, transparent 2px 6px); align-self: center; }
.m-line .num { color: var(--text); }
.m-line--save, .m-line--save .num { color: var(--gold); }
.m-empty { color: var(--dim); font-size: 16px; }
.m-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--gold); box-shadow: 0 -4px 0 -3px var(--bg), 0 -5px 0 -3px var(--gold); }
.m-total b { font-family: var(--f-display); font-weight: 700; font-size: 34px; letter-spacing: .01em; font-variant-numeric: lining-nums tabular-nums; }
.m-go { width: 100%; margin-top: var(--s5); justify-content: space-between; }
.m-go .btn__t { flex: 1; }
.m-msg { margin-top: var(--s4); font-size: 16px; color: var(--muted); min-height: 0; max-height: 0; overflow: hidden; opacity: 0; transition: opacity .4s, max-height .4s; }
.m-msg.is-on { opacity: 1; max-height: 80px; border-left: 2px solid var(--war); padding-left: var(--s3); }

@media (max-width: 899px) {
  .modal__sheet { width: 100%; border-left: 0; }
  .modal__scroll { padding: var(--s5) 20px var(--s4); }
  .m-foot { padding: var(--s4) 20px var(--s5); }
  .m-meta { grid-template-columns: repeat(3, auto); }
  .m-title { font-size: 30px; }
  .ledger__btn { grid-template-columns: 22px minmax(0, 1fr) auto; }
  .ledger__lead { display: none; }
}
@media (max-height: 640px) and (min-width: 900px) { .m-foot { padding-block: var(--s4); } }

@media (max-width: 899px) {
  .m-sum .m-line:not(.m-line--save) { display: none; }
  .m-sum .m-line:not(.m-line--save):only-of-type { display: grid; }
  .m-notice { margin-top: var(--s4); padding: var(--s3); font-size: 15px; }
  .m-sec { margin-top: var(--s5); }
  .m-total b { font-size: 28px; }
  .m-go { margin-top: var(--s4); min-height: 52px; }
  .m-foot { padding-top: var(--s4); }
}

/* short viewports (landscape phones, small laptops): keep totals and Reserve always on screen */
@media (max-height: 760px) {
  .m-sum .m-line:not(.m-line--save) { display: none; }
  .m-sum .m-line:not(.m-line--save):only-of-type { display: grid; }
  .m-foot { padding: var(--s3) var(--s5) var(--s4); }
  .modal__scroll { padding-top: var(--s4); }
  .m-total { margin-top: var(--s2); padding-top: var(--s2); }
  .m-total b { font-size: 26px; }
  .m-go { margin-top: var(--s3); min-height: 48px; }
  .m-msg.is-on { margin-top: var(--s2); max-height: 60px; font-size: 15px; }
  .m-notice { margin-top: var(--s3); padding: var(--s2) var(--s3); font-size: 14px; }
  .m-sec { margin-top: var(--s4); }
}
@media (max-height: 520px) {
  .m-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--s5); align-items: center; padding-block: var(--s2); }
  .m-sum { grid-column: 1; }
  .m-total { border-top: 0; box-shadow: none; margin: 0; padding: 0; }
  .m-line--save { display: none !important; }
  .m-go { grid-column: 2; margin: 0; width: auto; min-width: 220px; min-height: 44px; }
  .m-msg { grid-column: 1 / -1; }
  .m-meta { display: none; }
}
.modal__sheet { max-height: 100dvh; }
@media (max-width: 380px) { .m-title { font-size: 26px; } .m-chip { padding-inline: var(--s3); } .m-go .btn__t { padding-inline: var(--s4); } }
