/**
 * Meridian Log — order history instrument
 * Unique to orders.php · Big Shoulders Display + IBM Plex Sans
 * Independent of a36-ladder / grove / fan patterns
 */

:root {
  --ml-paper: #e9eef3;
  --ml-panel: #f7f9fb;
  --ml-ink: #141820;
  --ml-mute: #5a6574;
  --ml-coral: #e85d4c;
  --ml-steel: #3d7ea6;
  --ml-mint: #2a9d8f;
  --ml-sand: #c9a227;
  --ml-line: rgba(20, 24, 32, 0.1);
  --ml-display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --ml-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --ml-mono: "Martian Mono", ui-monospace, monospace;
  --ml-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ml-max: 1100px;
}

*,
*::before,
*::after { box-sizing: border-box; }

body.ml-orders {
  margin: 0;
  min-height: 100vh;
  font-family: var(--ml-body);
  color: var(--ml-ink);
  background: var(--ml-paper);
  -webkit-font-smoothing: antialiased;
}

body.ml-orders a { color: inherit; text-decoration: none; }
body.ml-orders button { font: inherit; color: inherit; }
body.ml-orders .ml-root button { cursor: pointer; border: none; background: none; padding: 0; }

.ml-root {
  position: relative;
  min-height: 100vh;
  overflow-x: visible;
  padding-bottom: calc(var(--kb-keybed-h, 132px) + 2.5rem);
}

body.ml-orders .a77-bare-main {
  display: block;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.ml-sky {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse 65% 40% at 85% -5%, rgba(61, 126, 166, 0.22), transparent 55%),
    radial-gradient(ellipse 50% 35% at 5% 30%, rgba(232, 93, 76, 0.12), transparent 50%),
    linear-gradient(185deg, #dfe7ef 0%, var(--ml-paper) 45%, #e6ebf1 100%);
}

.ml-sky::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent calc(12.5% - 1px),
      rgba(20, 24, 32, 0.04) calc(12.5% - 1px),
      rgba(20, 24, 32, 0.04) 12.5%
    );
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 70%);
}

.ml-sky::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, rgba(61, 126, 166, 0.35), transparent 80%);
  animation: mlMeridian 8s ease-in-out infinite alternate;
}

@keyframes mlMeridian {
  from { opacity: 0.35; transform: translateX(-8px); }
  to { opacity: 0.8; transform: translateX(8px); }
}

/* Mast */
.ml-mast {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  max-width: var(--ml-max);
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.4rem) clamp(1.1rem, 4vw, 2rem) 0;
}

.ml-brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.ml-brand-mark {
  font-family: var(--ml-mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ml-steel);
}

.ml-brand strong {
  font-family: var(--ml-display);
  font-size: clamp(1.55rem, 4.2vw, 2.55rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  max-width: 14ch;
}

.ml-brand em {
  font-style: normal;
  font-size: 0.95rem;
  color: var(--ml-mute);
}

.ml-count {
  text-align: right;
  font-family: var(--ml-mono);
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ml-mute);
}

.ml-count b {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--ml-display);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ml-ink);
  line-height: 1;
  text-transform: none;
}

/* Hero */
.ml-hero {
  position: relative;
  z-index: 2;
  max-width: var(--ml-max);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2.75rem) clamp(1.1rem, 4vw, 2rem) 1.25rem;
}

.ml-hero h1 {
  margin: 0 0 0.65rem;
  font-family: var(--ml-display);
  font-size: clamp(1.55rem, 3vw, 2.1rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  line-height: 1.05;
}

.ml-hero p {
  margin: 0;
  max-width: 42ch;
  color: var(--ml-mute);
  line-height: 1.55;
  font-size: 1.02rem;
}

.ml-shell {
  position: relative;
  z-index: 2;
  max-width: var(--ml-max);
  margin: 0 auto;
  padding: 0 clamp(1.1rem, 4vw, 2rem) 1.5rem;
}

/* Loading */
.ml-loading {
  padding: 2rem 1.25rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed var(--ml-line);
  font-family: var(--ml-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ml-mute);
  text-align: center;
}

.ml-loading::after {
  content: "";
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  margin-left: 0.55rem;
  border-radius: 50%;
  background: var(--ml-coral);
  vertical-align: middle;
  animation: mlBlink 1.2s ease-in-out infinite;
}

@keyframes mlBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

/* Guest gate */
.ml-gate {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 0;
  border-radius: 16px;
  overflow: hidden;
  background: var(--ml-panel);
  box-shadow: 0 20px 50px rgba(20, 24, 32, 0.08);
  border: 1px solid var(--ml-line);
}

.ml-gate-aside {
  padding: clamp(1.5rem, 3vw, 2.25rem);
  background: linear-gradient(165deg, #1a2230, #141820);
  color: #e8eef4;
}

.ml-gate-aside h2 {
  margin: 0 0 0.5rem;
  font-family: var(--ml-display);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}

.ml-gate-aside p {
  margin: 0;
  color: rgba(232, 238, 244, 0.7);
  line-height: 1.5;
  max-width: 28ch;
}

.ml-gate-body {
  padding: clamp(1.5rem, 3vw, 2.25rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
}

.ml-gate-body p {
  margin: 0;
  color: var(--ml-mute);
  line-height: 1.5;
}

.ml-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.ml-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.25rem;
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: 999px;
  transition: transform 0.25s var(--ml-ease), background 0.25s;
}

.ml-btn:hover { transform: translateY(-1px); }

.ml-btn--ink {
  background: var(--ml-ink);
  color: #fff !important;
}

.ml-btn--ink:hover { background: #242a36; }

.ml-btn--steel {
  background: var(--ml-steel);
  color: #fff !important;
}

.ml-btn--steel:hover { background: #4a8fb8; }

.ml-btn--ghost {
  box-shadow: inset 0 0 0 1.5px var(--ml-line);
  color: var(--ml-ink) !important;
}

.ml-btn--ghost:hover {
  box-shadow: inset 0 0 0 1.5px var(--ml-ink);
}

.ml-btn--coral {
  background: var(--ml-coral);
  color: #fff !important;
}

.ml-btn--sm {
  padding: 0.55rem 0.95rem;
  font-size: 0.82rem;
}

/* Archive head */
.ml-archive-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.ml-archive-head h2 {
  margin: 0;
  font-family: var(--ml-display);
  font-size: 1.35rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}

.ml-archive-head span {
  font-family: var(--ml-mono);
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ml-mute);
}

/* Order slips */
.ml-list {
  display: grid;
  gap: 1rem;
}

.ml-slip {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr) minmax(12rem, 16rem);
  gap: 0;
  border-radius: 14px;
  overflow: hidden;
  background: var(--ml-panel);
  border: 1px solid var(--ml-line);
  box-shadow: 0 12px 36px rgba(20, 24, 32, 0.06);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.55s var(--ml-ease), transform 0.55s var(--ml-ease), border-color 0.3s;
}

.ml-slip.is-in {
  opacity: 1;
  transform: none;
}

.ml-slip:hover {
  border-color: rgba(61, 126, 166, 0.35);
}

/* Date cylinder */
.ml-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 1.1rem 0.5rem;
  background: linear-gradient(180deg, #1a2230, #141820);
  color: #e8eef4;
  text-align: center;
  position: relative;
}

.ml-date::before,
.ml-date::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 18px;
  height: 6px;
  margin-left: -9px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
}

.ml-date::before { top: 8px; }
.ml-date::after { bottom: 8px; }

.ml-date-day {
  font-family: var(--ml-display);
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.ml-date-mon {
  font-family: var(--ml-mono);
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ml-coral);
}

.ml-date-yr {
  font-size: 0.72rem;
  color: rgba(232, 238, 244, 0.55);
}

/* Main body */
.ml-body {
  padding: 1.1rem 1.2rem;
  display: grid;
  gap: 0.75rem;
  align-content: start;
  min-width: 0;
}

.ml-body-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.ml-id {
  margin: 0;
  font-family: var(--ml-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  line-height: 1.1;
  word-break: break-word;
}

.ml-seq {
  font-family: var(--ml-mono);
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ml-mute);
}

/* Tracking state — signal meter */
.ml-signal {
  display: grid;
  gap: 0.4rem;
}

.ml-signal-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.ml-signal-label strong {
  font-weight: 600;
  color: var(--ml-ink);
}

.ml-signal-label span {
  font-family: var(--ml-mono);
  font-size: 0.52rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ml-mute);
}

.ml-meter {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  height: 8px;
}

.ml-meter i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: rgba(20, 24, 32, 0.08);
  transition: background 0.35s;
}

.ml-slip.tone-placed .ml-meter i:nth-child(1) { background: var(--ml-sand); }
.ml-slip.tone-packed .ml-meter i:nth-child(-n+2) { background: var(--ml-steel); }
.ml-slip.tone-shipped .ml-meter i:nth-child(-n+3) { background: var(--ml-coral); }
.ml-slip.tone-delivered .ml-meter i { background: var(--ml-mint); }
.ml-slip.tone-cancelled .ml-meter i {
  background: rgba(20, 24, 32, 0.15);
}
.ml-slip.tone-cancelled .ml-meter i:nth-child(1) {
  background: #8a9099;
}

.ml-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 0;
  font-size: 0.88rem;
  color: var(--ml-mute);
}

.ml-meta div {
  display: flex;
  gap: 0.4rem;
}

.ml-meta dt {
  font-family: var(--ml-mono);
  font-size: 0.52rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  align-self: center;
}

.ml-meta dd {
  margin: 0;
  color: var(--ml-ink);
  font-weight: 600;
}

.ml-items {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ml-mute);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Invoice slip panel */
.ml-invoice {
  padding: 1rem 1.1rem;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 14px,
      rgba(61, 126, 166, 0.06) 14px,
      rgba(61, 126, 166, 0.06) 15px
    ),
    linear-gradient(180deg, #f0f4f8, #e8eef4);
  border-left: 1px dashed rgba(20, 24, 32, 0.15);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 100%;
}

.ml-invoice-tag {
  font-family: var(--ml-mono);
  font-size: 0.52rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ml-steel);
}

.ml-invoice-total {
  font-family: var(--ml-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  text-transform: uppercase;
}

.ml-invoice-line {
  font-size: 0.8rem;
  color: var(--ml-mute);
  line-height: 1.4;
}

.ml-invoice-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.ml-invoice-actions a {
  text-align: center;
}

/* Empty */
.ml-empty {
  text-align: center;
  padding: clamp(2rem, 5vw, 3rem) 1.25rem;
  border-radius: 16px;
  border: 1px dashed var(--ml-line);
  background: rgba(255, 255, 255, 0.5);
}

.ml-empty-orb {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  border: 2px solid var(--ml-ink);
  position: relative;
}

.ml-empty-orb::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  border: 1.5px dashed var(--ml-steel);
  animation: mlSpin 10s linear infinite;
}

@keyframes mlSpin {
  to { transform: rotate(360deg); }
}

.ml-empty h2 {
  margin: 0 0 0.45rem;
  font-family: var(--ml-display);
  font-size: 1.7rem;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}

.ml-empty p {
  margin: 0 auto 1.25rem;
  max-width: 36ch;
  color: var(--ml-mute);
  line-height: 1.5;
}

/* Colophon */
.ml-colophon {
  position: relative;
  z-index: 2;
  max-width: var(--ml-max);
  margin: 1rem auto 0;
  padding: 1.25rem clamp(1.1rem, 4vw, 2rem) 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: center;
  border-top: 1px solid var(--ml-line);
  font-size: 0.85rem;
  color: var(--ml-mute);
}

.ml-colophon strong {
  font-family: var(--ml-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  color: var(--ml-ink);
}

.ml-colophon nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.ml-colophon nav a:hover { color: var(--ml-steel); }

[data-ml-rise] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.55s var(--ml-ease), transform 0.55s var(--ml-ease);
  transition-delay: calc(var(--ml-delay, 0) * 70ms);
}

[data-ml-rise].is-in {
  opacity: 1;
  transform: none;
}

.ml-root[data-ml-ready="0"] [data-ml-rise],
.ml-root[data-ml-ready="0"] .ml-slip {
  animation: ml-rise-fallback 0.01s linear 1.4s forwards;
}

@keyframes ml-rise-fallback {
  to { opacity: 1; transform: none; }
}

@media (max-width: 860px) {
  .ml-gate {
    grid-template-columns: 1fr;
  }

  .ml-slip {
    grid-template-columns: 4.75rem minmax(0, 1fr);
  }

  .ml-invoice {
    grid-column: 1 / -1;
    border-left: none;
    border-top: 1px dashed rgba(20, 24, 32, 0.15);
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .ml-invoice-actions {
    margin-top: 0;
    margin-left: auto;
    flex-direction: row;
    flex-wrap: wrap;
  }
}

@media (max-width: 520px) {
  .ml-mast {
    flex-direction: column;
    align-items: flex-start;
  }

  .ml-count { text-align: left; }

  .ml-slip {
    grid-template-columns: 1fr;
  }

  .ml-date {
    flex-direction: row;
    gap: 0.65rem;
    padding: 0.75rem 1rem;
    justify-content: flex-start;
  }

  .ml-date::before,
  .ml-date::after { display: none; }

  .ml-date-day { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ml-sky::after,
  .ml-loading::after,
  .ml-empty-orb::before,
  .ml-slip,
  [data-ml-rise] {
    animation: none !important;
    transition: none !important;
    opacity: 1;
    transform: none;
  }
}
