/**
 * Sheet styles
 * @countermeasure/web-components/overlays/sheet
 */

/* ============================================================================
   OVERLAY BACKDROP
   ============================================================================ */
.cmm-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay, 300);
  background-color: rgb(0 0 0 / 0.5); /* TODO(phase-1): tokenize — backdrop overlay */
  opacity: 0;
  transition: opacity var(--transition-normal, 200ms) ease-out;
}

.cmm-sheet-overlay--open {
  opacity: 1;
}

/* ============================================================================
   PANEL BASE
   ============================================================================ */
.cmm-sheet {
  position: fixed;
  z-index: var(--z-overlay, 300);
  display: flex;
  flex-direction: column;
  background-color: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  box-shadow: var(--shadow-xl);
  transition: transform var(--transition-slow, 300ms) cubic-bezier(0.32, 0.72, 0, 1);
}

/* ============================================================================
   SIDE POSITIONING
   ============================================================================ */
.cmm-sheet--right {
  top: 0;
  right: 0;
  bottom: 0;
  border-left: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  transform: translateX(100%);
}

.cmm-sheet--left {
  top: 0;
  left: 0;
  bottom: 0;
  border-right: 1px solid hsl(var(--border));
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  transform: translateX(-100%);
}

.cmm-sheet--top {
  top: 0;
  left: 0;
  right: 0;
  border-bottom: 1px solid hsl(var(--border));
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  transform: translateY(-100%);
}

.cmm-sheet--bottom {
  bottom: 0;
  left: 0;
  right: 0;
  border-top: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  transform: translateY(100%);
}

/* Open state resets transforms */
.cmm-sheet--open {
  transform: translate(0, 0);
}

/* ============================================================================
   SIZE VARIANTS (horizontal sheets: left/right)
   ============================================================================ */
.cmm-sheet--right.cmm-sheet--sm,
.cmm-sheet--left.cmm-sheet--sm {
  width: 320px;
}

.cmm-sheet--right.cmm-sheet--md,
.cmm-sheet--left.cmm-sheet--md {
  width: 480px;
}

.cmm-sheet--right.cmm-sheet--lg,
.cmm-sheet--left.cmm-sheet--lg {
  width: 640px;
}

.cmm-sheet--right.cmm-sheet--xl,
.cmm-sheet--left.cmm-sheet--xl {
  width: 800px;
}

.cmm-sheet--right.cmm-sheet--full,
.cmm-sheet--left.cmm-sheet--full {
  width: 100%;
}

/* SIZE VARIANTS (vertical sheets: top/bottom) */
.cmm-sheet--top.cmm-sheet--sm,
.cmm-sheet--bottom.cmm-sheet--sm {
  height: 320px;
}

.cmm-sheet--top.cmm-sheet--md,
.cmm-sheet--bottom.cmm-sheet--md {
  height: 480px;
}

.cmm-sheet--top.cmm-sheet--lg,
.cmm-sheet--bottom.cmm-sheet--lg {
  height: 640px;
}

.cmm-sheet--top.cmm-sheet--xl,
.cmm-sheet--bottom.cmm-sheet--xl {
  height: 800px;
}

.cmm-sheet--top.cmm-sheet--full,
.cmm-sheet--bottom.cmm-sheet--full {
  height: 100%;
}

/* ============================================================================
   HEADER
   ============================================================================ */
.cmm-sheet__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
  flex-shrink: 0;
}

.cmm-sheet__header-text {
  flex: 1;
  min-width: 0;
}

.cmm-sheet__title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
  color: hsl(var(--foreground));
}

.cmm-sheet__description {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: hsl(var(--muted-foreground));
}

.cmm-sheet__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background-color: transparent;
  color: hsl(var(--muted-foreground));
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--transition-fast, 150ms);
}

.cmm-sheet__close:hover {
  background-color: hsl(var(--muted));
  color: hsl(var(--foreground));
}

.cmm-sheet__close:focus-visible {
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: 2px;
}

/* ============================================================================
   BODY (SCROLLABLE)
   ============================================================================ */
.cmm-sheet__body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.cmm-sheet__body:focus-visible {
  outline: none;
}
