/*
 * Model Monkey Lighting & Depth System
 *
 * Surfaces use an absolute 0-255 depth coordinate. The procedural engine
 * calculates each cast from caster depth minus receiver depth. Current UI
 * static assignments stop at 200; transient button hover can reach 222, so
 * levels 223-255 remain available for expansion.
 */

:root {
  --mm-lighting-duration: 1.4s;
  --mm-lighting-easing: cubic-bezier(0.37, 0, 0.63, 1);
  --mm-hover-duration: 0.46s;
  --mm-hover-easing: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Preserve the original translucent colour language on tab faces. */
.side-tab#tab-btn-intro { background: var(--tab-intro-card); }
.side-tab#tab-btn-token { background: var(--tab-token-card); }
.side-tab#tab-btn-text { background: var(--tab-text-card); }
.side-tab#tab-btn-image { background: var(--tab-image-card); }
.side-tab#tab-btn-four { background: var(--tab-four-card); }
.side-tab#tab-btn-model { background: var(--tab-model-card); }
.side-tab#tab-btn-info { background: rgba(139, 124, 246, 0.4); }

.soft-card,
.paypal-card {
  --inner-card-title-surface: var(--surface);
  --inner-card-title-contrast: var(--text);
}

.info-block-intro {
  --inner-card-title-surface: var(--tab-intro-card);
  --inner-card-title-contrast: var(--tab-intro-text);
}

.info-block-token {
  --inner-card-title-surface: var(--tab-token-card);
  --inner-card-title-contrast: var(--tab-token-text);
}

.info-block-text {
  --inner-card-title-surface: var(--tab-text-card);
  --inner-card-title-contrast: var(--tab-text-text);
}

.info-block-image {
  --inner-card-title-surface: var(--tab-image-card);
  --inner-card-title-contrast: var(--tab-image-text);
}

.info-block-four {
  --inner-card-title-surface: var(--tab-four-card);
  --inner-card-title-contrast: var(--tab-four-text);
}

.info-block-model {
  --inner-card-title-surface: var(--tab-model-card);
  --inner-card-title-contrast: var(--tab-model-text);
}

body[data-theme] .inner-card-title {
  color: color-mix(
    in srgb,
    var(--inner-card-title-surface, var(--surface)) 56%,
    var(--inner-card-title-contrast, var(--text)) 44%
  );
}

body[data-theme] .metric-label.inner-card-title,
body[data-theme] .upload-title.inner-card-title,
body[data-theme] .paypal-card > .inner-card-title {
  font-size: 22px;
}

body[data-theme] .paypal-card > .inner-card-title {
  font-weight: 500;
  letter-spacing: normal;
  line-height: 1.3;
}

body[data-theme] .info-block > .inner-card-title {
  font-size: 26px;
}

body[data-theme] .paypal-card,
body[data-theme] .paypal-card * {
  font-family: "Roboto", Arial, sans-serif;
  font-style: normal;
  font-weight: 300;
  letter-spacing: -0.03em;
}

body[data-theme] .paypal-card .paypal-quantity-wrap > label {
  font-size: 22px;
}

/* Every external cast below is generated by the depth engine. */
.panel-host,
.global-status,
.loading-status-bar,
body[data-theme] .side-tab.active,
body[data-theme] .side-tab.active:hover {
  box-shadow: var(--mm-depth-shadow, none);
}

.soft-card,
.paypal-card {
  box-shadow: var(--mm-depth-shadow, none);
}

.paypal-step-button,
.primary-action,
.secondary-action {
  box-shadow: var(--mm-depth-shadow, none);
}

/* Disabled state mutes the face, not the physical shadow or depth. */
.primary-action:disabled,
.secondary-action:disabled {
  opacity: 1;
  color: var(--muted);
}

.primary-token-tab:disabled {
  background: color-mix(in srgb, var(--tab-token) 55%, var(--panel));
}

.primary-text-tab:disabled {
  background: color-mix(in srgb, var(--tab-text) 55%, var(--panel));
}

.primary-image-tab:disabled {
  background: color-mix(in srgb, var(--tab-image) 55%, var(--panel));
}

.primary-four-tab:disabled {
  background: color-mix(in srgb, var(--tab-four) 55%, var(--panel));
}

.primary-model-tab:disabled {
  background: color-mix(in srgb, var(--tab-model) 55%, var(--panel));
}

.secondary-action:disabled {
  background: color-mix(in srgb, var(--secondary-bg) 58%, var(--panel));
}

.theme-toggle-track,
.theme-toggle-track[data-mm-depth="0"],
.theme-toggle-thumb,
.paypal-button-container {
  box-shadow: var(--mm-depth-shadow, none);
}

body[data-theme] .side-tab:not(.active) {
  box-shadow: var(--mm-depth-shadow, none);
}

body[data-theme] .side-tab:not(.active):hover {
  box-shadow: var(--mm-depth-shadow, none);
}

/*
 * The real open tab is above the card and therefore casts its 129->128
 * contact shadow directly. This receiver-clipped layer supplies its stronger
 * 129->0 cast only outside the card, where the receiver is the background.
 */
body[data-theme] .side-tab.active,
body[data-theme] .side-tab.active:hover {
  z-index: 3;
}

.panel-host {
  isolation: isolate;
}

.panel-host::before {
  content: "";
  position: absolute;
  left: var(--mm-tab-cast-left, 0px);
  top: var(--mm-tab-cast-top, 0px);
  z-index: 0;
  width: var(--mm-tab-cast-width, 0px);
  height: var(--mm-tab-cast-height, 0px);
  border-radius: var(--mm-tab-cast-radius, 0px);
  background: transparent;
  box-shadow: var(--mm-tab-background-shadow, none);
  clip-path: inset(
    var(--mm-background-clip-top, 0)
    var(--mm-background-clip-right, 0)
    var(--mm-background-clip-bottom, 0)
    var(--mm-background-clip-left, 0)
  );
  pointer-events: none;
}

/*
 * The open tab's shadow silhouette is projected onto the background receiver.
 * Because this layer sits beneath the translucent tab, the same procedural
 * cast is visible through the tab face rather than being painted inside it.
 */
.panel-host::after {
  content: "";
  position: absolute;
  left: var(--mm-tab-projection-left, 0px);
  top: var(--mm-tab-projection-top, 0px);
  z-index: 0;
  width: var(--mm-tab-cast-width, 0px);
  height: var(--mm-tab-cast-height, 0px);
  border-radius: var(--mm-tab-cast-radius, 0px);
  background: var(--mm-tab-projection-colour, transparent);
  filter: blur(var(--mm-tab-projection-blur, 0px));
  clip-path: inset(
    var(--mm-projection-clip-top, 0)
    var(--mm-projection-clip-right, 0)
    var(--mm-projection-clip-bottom, 0)
    var(--mm-projection-clip-left, 0)
  );
  pointer-events: none;
}

.panel-host > .panel {
  position: relative;
  z-index: 1;
}

@media (hover: hover) and (pointer: fine) {
  body[data-theme] .side-tab:not(.active),
  body[data-theme] .primary-action,
  body[data-theme] .secondary-action,
  body[data-theme] .paypal-step-button {
    transition:
      transform var(--mm-hover-duration) var(--mm-hover-easing),
      filter var(--mm-hover-duration) var(--mm-hover-easing);
  }

  body[data-theme] .side-tab:not(.active):hover,
  body[data-theme] .primary-action:not(:disabled):hover,
  body[data-theme] .secondary-action:not(:disabled):hover,
  body[data-theme] .paypal-step-button:not(:disabled):hover {
    transform: translateY(-2px);
  }

  body[data-theme] .primary-action:active,
  body[data-theme] .secondary-action:active,
  body[data-theme] .paypal-step-button:active,
  body[data-theme] .primary-action:disabled:hover,
  body[data-theme] .secondary-action:disabled:hover,
  body[data-theme] .paypal-step-button:disabled:hover {
    transform: translateY(0);
  }
}

body.mm-lighting-transition,
body.mm-lighting-transition *,
body.mm-lighting-transition *::before,
body.mm-lighting-transition *::after {
  transition-property:
    background-color,
    color,
    border-color,
    outline-color,
    text-decoration-color,
    fill,
    stroke;
  transition-duration: var(--mm-lighting-duration);
  transition-timing-function: var(--mm-lighting-easing);
}

body.mm-lighting-transition .primary-action,
body.mm-lighting-transition .secondary-action {
  transition-property:
    transform,
    opacity,
    background-color,
    color,
    border-color,
    outline-color,
    text-decoration-color,
    fill,
    stroke;
  transition-duration:
    var(--mm-hover-duration),
    0.16s,
    var(--mm-lighting-duration),
    var(--mm-lighting-duration),
    var(--mm-lighting-duration),
    var(--mm-lighting-duration),
    var(--mm-lighting-duration),
    var(--mm-lighting-duration),
    var(--mm-lighting-duration);
  transition-timing-function:
    var(--mm-hover-easing),
    ease,
    var(--mm-lighting-easing),
    var(--mm-lighting-easing),
    var(--mm-lighting-easing),
    var(--mm-lighting-easing),
    var(--mm-lighting-easing),
    var(--mm-lighting-easing),
    var(--mm-lighting-easing);
}

body.mm-lighting-transition .theme-toggle-thumb {
  transition-property: left, background-color, color, border-color, outline-color;
  transition-duration:
    var(--mm-lighting-duration),
    var(--mm-lighting-duration),
    var(--mm-lighting-duration),
    var(--mm-lighting-duration),
    var(--mm-lighting-duration);
  transition-timing-function:
    var(--mm-lighting-easing),
    var(--mm-lighting-easing),
    var(--mm-lighting-easing),
    var(--mm-lighting-easing),
    var(--mm-lighting-easing);
}

body.mm-lighting-transition .panel-host::after {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  body.mm-lighting-transition,
  body.mm-lighting-transition *,
  body.mm-lighting-transition *::before,
  body.mm-lighting-transition *::after {
    transition-duration: 0s !important;
    transition-delay: 0s !important;
  }
}
