/* Shared UI Core surfaces. The shell overlays content; it must not enter page flow. */

.ui-surface[hidden] {
  display: none !important;
}

.ui-surface:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: grid;
  padding: clamp(0.5rem, 3vw, 1.5rem);
  isolation: isolate;
  align-items: center;
  justify-items: center;
}

.ui-surface__backdrop {
  position: absolute;
  inset: 0;
  background: light-dark(rgb(15 32 38 / 42%), rgb(0 0 0 / 65%));
  backdrop-filter: blur(6px);
  animation: ui-surface-fade 0.2s ease-out;
}

.ui-surface__panel {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(100%, 42rem);
  max-height: min(88dvh, 56rem);
  margin: auto;
  padding: clamp(1.25rem, 3vw, 2rem);
  overflow: auto;
  flex-direction: column;
  gap: 1rem;
  overscroll-behavior: contain;
  color: var(--color-ink);
  background: var(--color-surface);
  border: 1px solid var(--surface-border, var(--color-line));
  border-radius: var(--radius-xl, 1.25rem);
  box-shadow:
    0 2px 6px light-dark(rgb(10 28 34 / 6%), rgb(0 0 0 / 30%)),
    0 28px 64px light-dark(rgb(10 28 34 / 18%), rgb(0 0 0 / 55%));
  animation: ui-surface-rise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ui-surface--offcanvas .ui-surface__panel {
  animation-name: ui-surface-slide;
}

@keyframes ui-surface-fade {
  from {
    opacity: 0;
  }
}

/* Panels animate position only: if an animation is paused (background tab, print, capture),
   the panel stays fully opaque and readable. */

@keyframes ui-surface-rise {
  from {
    transform: translateY(0.75rem) scale(0.98);
  }
}

@keyframes ui-surface-slide {
  from {
    transform: translateX(2rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ui-surface__backdrop,
  .ui-surface__panel {
    animation: none;
  }
}

.ui-surface--modal:not([hidden]) .ui-surface__panel {
  width: min(100%, 42rem);
}

.ui-surface--offcanvas:not([hidden]) {
  display: flex;
  padding: 0;
  align-items: stretch;
  justify-content: flex-end;
}

/* Prototype drawer: square edge flush with the viewport, soft left shadow and a header strip
   separated by a line. The first intro/header block bleeds to the panel edges. */

.ui-surface--offcanvas .ui-surface__panel {
  --surface-pad-y: 1.5rem;
  --surface-pad-x: 1.5625rem;
  width: min(36rem, calc(100vw - 1rem));
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: var(--surface-pad-y) var(--surface-pad-x);
  border: 0;
  border-radius: 0;
  box-shadow: -12px 0 50px light-dark(rgb(23 46 56 / 20%), rgb(0 0 0 / 55%));
}

.ui-surface--offcanvas .ui-surface__panel > :is(.ui-surface__intro, .ui-surface__header) {
  margin: calc(-1 * var(--surface-pad-y)) calc(-1 * var(--surface-pad-x)) 0.25rem;
  padding: 1.375rem calc(var(--surface-pad-x) + 2.5rem) 1.25rem var(--surface-pad-x);
  border-bottom: 1px solid var(--surface-border, var(--color-line));
}

.ui-surface__panel :is(.ui-surface__intro, .ui-surface__header) :is(h2, .h3) {
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.ui-surface--offcanvas .ui-surface__panel--double {
  width: min(56rem, calc(100vw - 1rem));
}

.ui-surface__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 2;
  display: inline-grid;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  color: var(--color-ink-soft);
  background: var(--color-surface-soft);
  border: 1px solid transparent;
  border-radius: 50%;
  font: inherit;
  font-size: 1.35rem;
  line-height: 1;
  place-items: center;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.ui-surface__close:hover {
  color: var(--color-ink);
  background: light-dark(#eaf0ee, #26363f);
}

.ui-surface__close:focus-visible {
  outline: 3px solid var(--color-brand);
  outline-offset: 2px;
}

body.ui-surface-open {
  overflow: hidden;
}

.ui-surface__intro {
  display: grid;
  gap: 0.65rem;
  padding-right: 2.5rem;
}

.ui-surface__intro > :last-child {
  margin-bottom: 0;
}

.ui-confirm-delete__header {
  display: grid;
  gap: 0.65rem;
  padding-right: 2.5rem;
}

.ui-confirm-delete__header > :last-child {
  margin-bottom: 0;
  color: var(--color-ink-soft);
}

.ui-confirm-delete__form {
  display: grid;
  gap: 1rem;
}

.ui-confirm-delete__form > .d-flex {
  justify-content: flex-end;
}

@media (max-width: 52rem) {
  .ui-surface--modal .ui-surface__panel {
    width: min(100%, 40rem);
    max-height: calc(100dvh - 1rem);
  }
}

@media (max-width: 36rem) {
  .ui-surface--modal:not([hidden]) {
    padding: 0.5rem;
  }

  .ui-surface--modal .ui-surface__panel {
    width: 100%;
    max-height: calc(100dvh - 1rem);
    padding: 1.25rem 1rem;
    border-radius: 0.8rem;
  }

  .ui-surface--offcanvas .ui-surface__panel,
  .ui-surface--offcanvas .ui-surface__panel--double {
    width: 100vw;
    border-radius: 0;
  }
}
