/* Pixel borders apply only to the outer search, state and profile panels. */
:root {
  --mc-pixel: 0.25rem;
  --mc-pixel-small: 0.125rem;
  --mc-pixel-inset: 0.0625rem;
  --mc-panel-corner: 4px;
  --mc-panel-slice: 5;
  --mc-edge-top: color-mix(in srgb, var(--ink) 22%, var(--panel-2));
  --mc-edge-left: color-mix(in srgb, var(--ink) 12%, var(--panel-2));
  --mc-edge-right: color-mix(in srgb, var(--panel-2) 72%, black);
  --mc-edge-bottom: color-mix(in srgb, var(--panel-2) 46%, black);
  --mc-edge-shadow: color-mix(in srgb, var(--panel-2) 22%, black);
  --mc-inset-light: color-mix(in srgb, var(--ink) 12%, transparent);
  --mc-inset-dark: color-mix(in srgb, black 35%, transparent);
  --mc-action-light: color-mix(in srgb, var(--lime-bright) 65%, var(--ink));
  --mc-action-left: var(--lime);
  --mc-action-dark: color-mix(in srgb, var(--lime) 48%, black);
  --mc-focus: var(--lime-bright);
  --mc-panel-border-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' shape-rendering='crispEdges'%3E%3Crect x='5' y='0' width='5' height='5' fill='%23c5ff63'/%3E%3Crect x='0' y='5' width='5' height='5' fill='%23c5ff63'/%3E%3Crect x='10' y='5' width='5' height='5' fill='%234f872e'/%3E%3Crect x='5' y='10' width='5' height='5' fill='%234f872e'/%3E%3C/svg%3E");
  --mc-recessed:
    inset var(--mc-pixel-small) var(--mc-pixel-small) 0 var(--mc-inset-dark),
    inset calc(-1 * var(--mc-pixel-small)) calc(-1 * var(--mc-pixel-small)) 0 var(--mc-inset-light);
}

html[data-theme="brand"] {
  --mc-action-light: color-mix(in srgb, var(--gold) 65%, var(--ink));
  --mc-action-left: var(--ember-bright);
  --mc-action-dark: color-mix(in srgb, var(--ember) 48%, black);
  --mc-focus: var(--gold);
  --mc-panel-border-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' shape-rendering='crispEdges'%3E%3Crect x='5' y='0' width='5' height='5' fill='%23fcd950'/%3E%3Crect x='0' y='5' width='5' height='5' fill='%23fcd950'/%3E%3Crect x='10' y='5' width='5' height='5' fill='%23995617'/%3E%3Crect x='5' y='10' width='5' height='5' fill='%23995617'/%3E%3C/svg%3E");
}

/* Four transparent corner squares and equal top/left and bottom/right tones.
   No inner bevel, extra rim or double step is added to these panels. */
html[data-theme] :is(
  .search-shell, .welcome-state, .error-state, .profile-banner, .card
) {
  border-width: var(--mc-panel-corner) !important;
  border-style: solid !important;
  border-image: var(--mc-panel-border-image) var(--mc-panel-slice) / 1 / 0 stretch;
  background-clip: padding-box !important;
  border-radius: 0;
  box-shadow: none !important;
}

html[data-theme] body #search-form.search-shell {
  border-width: var(--mc-panel-corner) !important;
}

/* The search panel's old decorative stripe would duplicate its top edge. */
html[data-theme] .search-shell::before {
  content: none;
}

/* Preserve the previously accepted button bevels independently of panel borders. */
html[data-theme] :where(
  .search-row button, .secondary-button, .icon-button,
  .download-button, .copy-mini, #copy-head-command,
  .archive-name-more, .recent-searches button
) {
  --mc-step: var(--mc-pixel-small);
  --mc-top: var(--mc-edge-top);
  --mc-left: var(--mc-edge-left);
  --mc-right: var(--mc-edge-right);
  --mc-bottom: var(--mc-edge-bottom);
  --mc-frame:
    0 calc(-1 * var(--mc-step)) 0 var(--mc-top),
    calc(-1 * var(--mc-step)) 0 0 var(--mc-left),
    var(--mc-step) 0 0 var(--mc-right),
    0 var(--mc-step) 0 var(--mc-bottom),
    0 calc(2 * var(--mc-step)) 0 calc(-1 * var(--mc-step)) var(--mc-edge-shadow),
    calc(2 * var(--mc-step)) 0 0 calc(-1 * var(--mc-step)) var(--mc-edge-shadow),
    inset var(--mc-pixel-inset) var(--mc-pixel-inset) 0 var(--mc-inset-light),
    inset calc(-1 * var(--mc-pixel-small)) calc(-1 * var(--mc-pixel-small)) 0 var(--mc-inset-dark);
  border-radius: 0;
  box-shadow: var(--mc-frame) !important;
}

html[data-theme] :is(.search-row button, .secondary-button) {
  --mc-step: var(--mc-pixel);
  --mc-top: var(--mc-action-light);
  --mc-left: var(--mc-action-left);
  --mc-right: var(--mc-action-dark);
  --mc-bottom: var(--mc-action-dark);
}

html[data-theme] :is(
  .icon-button, .download-button, .archive-name-more, .recent-searches button
) {
  --mc-top: var(--mc-action-light);
  --mc-left: var(--mc-action-left);
  --mc-right: var(--mc-action-dark);
  --mc-bottom: var(--mc-action-dark);
  border-color: var(--mc-action-left);
}

html[data-theme] :is(
  .icon-button, .download-button, .copy-mini, #copy-head-command,
  .archive-name-more, .recent-searches button
):is(:hover, :focus-visible) {
  --mc-top: var(--mc-action-light);
  --mc-left: var(--mc-action-left);
}

html[data-theme] :is(.theme-switcher button, .pose-button) {
  --mc-inset-light: color-mix(in srgb, var(--mc-action-left) 36%, transparent);
  border-radius: 0;
  box-shadow:
    inset var(--mc-pixel-small) var(--mc-pixel-small) 0 var(--mc-inset-light),
    inset calc(-1 * var(--mc-pixel-small)) calc(-1 * var(--mc-pixel-small)) 0 var(--mc-inset-dark) !important;
}

html[data-theme] :is(
  .theme-switcher button[aria-pressed="true"], .pose-button.active
) {
  box-shadow:
    inset 0 calc(-1 * var(--mc-pixel)) 0 var(--mc-action-left),
    inset var(--mc-pixel-small) var(--mc-pixel-small) 0 var(--mc-inset-light) !important;
}

html[data-theme] :is(
  .search-row button, .secondary-button, .icon-button,
  .download-button, .copy-mini, #copy-head-command,
  .archive-name-more, .recent-searches button,
  .theme-switcher button, .pose-button
):active {
  box-shadow: var(--mc-recessed) !important;
}

html[data-theme] :is(button, a):focus-visible {
  outline: var(--mc-pixel-small) solid var(--mc-focus);
  outline-offset: calc(var(--mc-pixel) + var(--mc-pixel-small));
}
