/* Drawer (shadcn's Sheet and Drawer): UI SDK places the content in a full-screen viewport and
   slides it with translate, and fades the backdrop; this gives it a size, a surface and corners. */

@layer runeui.components {
  [data-slot="drawer-backdrop"] { position: fixed; inset: 0; z-index: 50; background: oklch(0 0 0 / 0.5); }

  [data-slot="drawer-content"] {
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--background);
    color: var(--foreground);
    box-shadow: var(--ui-shadow-lg);
    outline: none;
  }

  [data-slot="drawer-content"]:is([data-side="right"], [data-side="left"]) {
    width: min(75vw, 24rem);
    height: 100%;
    padding-block: 1rem;
  }
  [data-slot="drawer-content"][data-side="right"] { border-inline-start: 1px solid var(--border); }
  [data-slot="drawer-content"][data-side="left"] { border-inline-end: 1px solid var(--border); }
  [data-slot="drawer-content"]:is([data-side="right"], [data-side="left"])[data-size="sm"] { width: min(75vw, 20rem); }
  [data-slot="drawer-content"]:is([data-side="right"], [data-side="left"])[data-size="lg"] { width: min(90vw, 36rem); }
  [data-slot="drawer-content"]:is([data-side="right"], [data-side="left"])[data-size="full"] { width: 100vw; }

  [data-slot="drawer-content"]:is([data-side="top"], [data-side="bottom"]) {
    width: 100%;
    max-height: 80vh;
    padding-bottom: 1rem;
  }
  [data-slot="drawer-content"][data-side="bottom"] { border-top: 1px solid var(--border); border-radius: var(--ui-radius-xl) var(--ui-radius-xl) 0 0; padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
  [data-slot="drawer-content"][data-side="top"] { border-bottom: 1px solid var(--border); border-radius: 0 0 var(--ui-radius-xl) var(--ui-radius-xl); padding-top: 1rem; }
  [data-slot="drawer-content"]:is([data-side="top"], [data-side="bottom"])[data-size="lg"] { max-height: 92vh; }
  [data-slot="drawer-content"]:is([data-side="top"], [data-side="bottom"])[data-size="full"] { height: 100dvh; max-height: none; border-radius: 0; }
  /* Under a bottom sheet pulled up past its edge, more sheet rather than the page. */
  [data-slot="drawer-content"][data-side="bottom"]::after { content: ""; position: absolute; inset: 100% 0 auto; height: 100vh; background: inherit; }

  [data-slot="drawer-handle"] {
    display: block;
    flex-shrink: 0;
    width: 6.25rem;
    height: 0.375rem;
    margin: 1rem auto 0;
    border-radius: var(--ui-radius-full);
    background: var(--muted);
    cursor: grab;
  }
  [data-slot="drawer-content"][data-side="top"] [data-slot="drawer-handle"] { order: 99; margin: 0 auto; }

  [data-slot="drawer-header"] { display: flex; flex-direction: column; gap: 0.375rem; padding-inline: 1rem; }
  [data-slot="drawer-content"]:is([data-side="top"], [data-side="bottom"]) [data-slot="drawer-header"] { text-align: center; }
  @media (min-width: 768px) { [data-slot="drawer-content"]:is([data-side="top"], [data-side="bottom"]) [data-slot="drawer-header"] { text-align: start; } }
  [data-slot="drawer-title"] { font-weight: 600; color: var(--foreground); }
  [data-slot="drawer-description"] { color: var(--muted-foreground); font-size: var(--ui-text-sm); }
  [data-slot="drawer-body"] { flex: 1; min-height: 0; overflow-y: auto; padding-inline: 1rem; }
  [data-slot="drawer-footer"] { display: flex; flex-direction: column; gap: 0.5rem; margin-top: auto; padding-inline: 1rem; }

  [data-drawer-x] { position: absolute; top: 0.75rem; inset-inline-end: 0.75rem; opacity: 0.7; }
  @media (hover: hover) and (pointer: fine) { [data-drawer-x]:hover { opacity: 1; } }
}

/* The gallery's examples. */
@layer runeui.components {
  .ui-drawer-demo-form { display: grid; gap: 1rem; }
  .ui-drawer-demo-goal { margin: 1rem 0; text-align: center; font-size: 3.5rem; font-weight: 700; letter-spacing: -0.04em; line-height: 1; }
  .ui-drawer-demo-goal span { display: block; margin-top: 0.5rem; color: var(--muted-foreground); font-size: var(--ui-text-xs); font-weight: 400; letter-spacing: 0.08em; text-transform: uppercase; }
}
